Apexsql refactor question

I just download ApexSQL refactor in order to make some tests.

Unfortunately on of the first thing I tried return an error. (Invalid syntax near FOR.   In fact every single query using XML return a syntax from Refactor.  Does it exists a setting somewhere that will correct this behavior?


DECLARE @X XML

SELECT @X = (


SELECT ID [@ID],
[Name] [@Name]
FROM dbo.[MyTable] [A]
FOR XML PATH(N'MyTable'), ROOT(N'Objects'), TYPE


)

Parents
  • Hi Patrick, does the error comes up when you do a Format SQL with this code?

    I have tested with your code and it changed it from: 

    DECLARE @X XML
    SELECT @X = (
    
    SELECT ID [@ID], 
    [Name] [@Name]
    FROM dbo.[MyTable] [A] 
    FOR XML PATH(N'MyTable'), ROOT(N'Objects'), TYPE
    
    )

    To: 

    DECLARE @X XML
    SELECT @X =
    (
    	SELECT ID AS [@ID]
    		 , Name AS [@Name]
    	FROM dbo.MyTable AS A FOR XML PATH(N'MyTable'), ROOT(N'Objects'), TYPE
    )

    and threw no errors. 

    The test was performed on ApexSQL Refactor 2020.04.0423 inside SQL Server Management Studio v18.4

Reply
  • Hi Patrick, does the error comes up when you do a Format SQL with this code?

    I have tested with your code and it changed it from: 

    DECLARE @X XML
    SELECT @X = (
    
    SELECT ID [@ID], 
    [Name] [@Name]
    FROM dbo.[MyTable] [A] 
    FOR XML PATH(N'MyTable'), ROOT(N'Objects'), TYPE
    
    )

    To: 

    DECLARE @X XML
    SELECT @X =
    (
    	SELECT ID AS [@ID]
    		 , Name AS [@Name]
    	FROM dbo.MyTable AS A FOR XML PATH(N'MyTable'), ROOT(N'Objects'), TYPE
    )

    and threw no errors. 

    The test was performed on ApexSQL Refactor 2020.04.0423 inside SQL Server Management Studio v18.4

Children
No Data