What is the difference between following two statements ?
1. SELECT 'DotnetFunda' 'SQL Server'

2. SELECT 'DotnetFunda' = 'SQL Server'

 Posted by PandianS on 7/16/2010 | Category: Sql Server Interview questions | Views: 5046
Answer:

Difference between the two statements given below

1. SELECT 'DotnetFunda' 'SQL Server'

2. SELECT 'DotnetFunda' = 'SQL Server'

The value 'DotnetFunda' uses 'SQL Server' as an Alias name. Alias will be the column Name.
SELECT 'DotnetFunda' 'SQL Server'

Go
SQL Server
DotnetFunda

The value 'SQL Server' assignes to 'DotnetFunda'. Target will be the column Name.
SELECT 'DotnetFunda' = 'SQL Server'

Go
DotnetFunda
SQL Server


Asked In: SQL Server Logical | Alert Moderator 

Comments or Responses

Posted by: Kishork80 on: 7/20/2010
very tricky.thanks.
Posted by: Neeraaj.Sharma on: 6/24/2013 | Points: 10

First Statements :
SELECT 'DotnetFunda' 'SQL Server'

Result is : DotnetFunda and Sql server is Column Name, here you are specifying column name to value 'DotnetFunda'

If you run SELECT 'DotnetFunda'

Result (No column name)
DotnetFunda
because you have`t specified Column name to Value.






SELECT 'DotnetFunda' = 'SQL Server'

This is the Eye-catcher:

Result is : DotnetFunda
SQL Server


Here DotnetFunda is the Column Name And SQL Server is the result
Whats happening here actually :
database Engine creating a variable and assigning "SQL Server" As

Value to it as Aliasing it as DotnetFunda, has anybody find these kind of stuff in BOL?






www.tutorialsqlserver.com

Login to post response