Strange behavior of SQL Server Management studio

I am currently using SQL Server Management Studio (Ver 9.00.3042.00) and click New Query and wrote the following code:

Select 
    colA,
    colB,
    colC
    colD
From
    table1

      

When I click the parse (checkbox) button to validate the SQL statement, it says "Command completed successfully". Doesn't the parsing button let you catch these simple errors ...

Has anyone experienced this type of behavior in Management Studio? It just started happening this week ....

0


source to share


2 answers


This is because it really is SQL. You are effectively antialiasing colC named colD. This is the same as typing:

colC as colD

      



Edit: For what it's worth, this is one of the reasons why people would argue that you should put commas at the beginning of a line in such cases. It is much easier to spot errors like this when the code is formatted as such:

Select 
    colA
    , colB
    , colC
    colD
From
    table1

      

+14


source


After a little game it gives "Wrong syntax nearby" in the following code snippets



Select     
    colA,    
    colB    
    colC    
    colD
From    
    table1

Select     
    colA,    
    colB,    
    colC,    
    colD,
From    
    table1

      

0


source







All Articles