Reputation: 25290
I am currently using SQL Server Management Studio (Ver 9.00.3042.00) and click the "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(s) completed successfully". Isn't the parse button suppose to catch these simple errors...
Has anyone experienced this type of behavior from Management Studio? This just started happening this week....
Upvotes: 0
Views: 852
Reputation: 25290
After a little playing around, it throws the "Incorrect syntax near" on the following code snippets
Select
colA,
colB
colC
colD
From
table1
Select
colA,
colB,
colC,
colD,
From
table1
Upvotes: 0
Reputation: 11814
That's because that is valid SQL. You're effectively aliasing colC with the name colD. It's the same as typing:
colC as colD
Edit: For what it's worth, this is one of the reasons why people will argue that you should put the commas at the beginning of the line in cases like this. It's a lot easier to spot gotchas like this when the code is formatted as such:
Select
colA
, colB
, colC
colD
From
table1
Upvotes: 14