select @@version command

Hello Team,

I was running the query select @@version command which is showing the correct output. But if I run the command like:

select 22version then it gives output 22.

so putting any number in place of "@@", it will show that number. I believe it should through some syntax error or some other error rather than giving the output. 

I have checked this in sql server 2005, 2008, 2008R2, 2012 and 2014.

Please let me know if i am wrong at any place.

Regards,

Ruchi Dubey

September 11th, 2015 2:12am

Hello,

pretty easy: SQL Server parse the Statement, detect 22 as numeric and threat the rest as column alias and this is because a qualifier can start with an underscore or a letter, but nut with a number:

select 22version 
select 22 AS version 

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 2:41am

Hello,

pretty easy: SQL Server parse the Statement, detect 22 as numeric and threat the rest as column alias and this is because a qualifier can start with an underscore or a letter, but not with a number:

select 22version 
select 22 AS version 

September 11th, 2015 6:40am

Interesting! I would have thought it's a bug as we don't have a space here.
Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 11:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics