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: Today @ 3:42 AM
Points: 13,568, Visits: 11,377
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: Today @ 3:42 AM
Points: 13,568, Visits: 11,377
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: Thursday, October 16, 2014 10:02 AM
Points: 1,372, Visits: 1,566
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: Today @ 12:12 AM
Points: 1,953, Visits: 2,397
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: Thursday, October 16, 2014 10:02 AM
Points: 1,372, Visits: 1,566
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: Yesterday @ 12:36 AM
Points: 1,379, Visits: 510
An easy basic question! Thanks!
Post #1377430
Posted Friday, October 26, 2012 2:39 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 3:24 AM
Points: 4,121, Visits: 5,487
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: 2 days ago @ 11:25 AM
Points: 544, Visits: 298
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: Monday, November 24, 2014 10:03 AM
Points: 1,895, Visits: 2,194
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