Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««1234»»»

SELECT (Transact-SQL) Expand / Collapse
Author
Message
Posted Thursday, October 25, 2012 11:27 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 11:26 AM
Points: 13,622, Visits: 10,514
An easy one to close the week, thanks!



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1377398
Posted Thursday, October 25, 2012 11:28 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 11:26 AM
Points: 13,622, Visits: 10,514
kapil_kk (10/25/2012)
One question, I am confused on this...

select ID, name name from person

select ID ID, name name from person

Both these statements dont give any error message and run successfully...
wht is it so?


Think both statements as the following:

select ID, name [AS] name from person;

select ID [AS] ID, name [AS] name from person

The AS keyword is optional when used for aliases in the SELECT statement.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1377399
Posted Thursday, October 25, 2012 11:33 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:38 PM
Points: 1,371, Visits: 1,560
kapil_kk (10/25/2012)
One question, I am confused on this...

select ID, name name from person

select ID ID, name name from person

Both these statements dont give any error message and run successfully...
wht is it so?


'coz they are syntactically correct. They follow the belew rule

SELECT <column_name> [optional "AS" keyword] [optional <alias_name>]
FROM <table_name>


Alias_name can be same as that of column_name. Hope it is clear now


~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1377402
Posted Thursday, October 25, 2012 11:41 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, July 25, 2014 12:34 AM
Points: 1,888, Visits: 2,326
Thanks Koen and Lokesh :)


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1377405
Posted Thursday, October 25, 2012 11:46 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:38 PM
Points: 1,371, Visits: 1,560
demonfox (10/25/2012)
I found the glitch ..
nice question...

thanks


A trick to catch the glitch.
1) Use SSMS, go to "Query" and select "IntelliSense Enabled"
2) Copy paste the code
3) the syntax error in the query (with error) will be highlighted with zig-zag red line

Check the attached image.



~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter



  Post Attachments 
sql.jpg (182 views, 37.36 KB)
Post #1377407
Posted Friday, October 26, 2012 1:59 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 4:44 AM
Points: 1,327, Visits: 481
An easy basic question! Thanks!
Post #1377430
Posted Friday, October 26, 2012 2:39 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 5:18 AM
Points: 3,925, Visits: 5,112
Nice, simple, back-to-basics question, thanks

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1377436
Posted Friday, October 26, 2012 4:11 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 7:46 AM
Points: 538, Visits: 275
Lokesh Vij (10/25/2012)
demonfox (10/25/2012)
I found the glitch ..
nice question...

thanks


A trick to catch the glitch.
1) Use SSMS, go to "Query" and select "IntelliSense Enabled"
2) Copy paste the code
3) the syntax error in the query (with error) will be highlighted with zig-zag red line

Check the attached image.



Thanks to all!
Ps: don´t "copy paste the code", ok ?
Post #1377456
Posted Friday, October 26, 2012 5:21 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 8:26 AM
Points: 1,803, Visits: 2,168
Thanks for the question. A basic but clear one. Just right for a Friday. More?

Please don't go. The drones need you. They look up to you.
Connect to me on LinkedIn
Post #1377492
Posted Friday, October 26, 2012 5:59 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Thursday, June 12, 2014 4:19 AM
Points: 701, Visits: 1,145
Thanks. I needed an easy one for Friday. Confused me for a second with having 5 possible answers and showing only 4 examples but was awake enough to get it right.
Post #1377523
« Prev Topic | Next Topic »

Add to briefcase ««1234»»»

Permissions Expand / Collapse