May 13, 2010 at 8:58 pm
Comments posted to this topic are about the item Careful with table name alias
May 13, 2010 at 10:22 pm
May 13, 2010 at 10:56 pm
I think the results on this should be expected. I think the query was written interestingly enough.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
May 13, 2010 at 11:42 pm
It is very interesting. However, am still not clear on [flag ='y' ]. Can someone tell me what is this flag. I didnt get any content in BOL.
thanks
erajendar
May 13, 2010 at 11:59 pm
Good question, although not that hard (for 2 points).
erajendar (5/13/2010)
It is very interesting. However, am still not clear on [flag ='y' ]. Can someone tell me what is this flag. I didnt get any content in BOL.
The flag isn't actually there. Since it is contained in brackets, it is just an alias name for the table.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
May 14, 2010 at 12:04 am
very interesting, this table alias in select clause got me puzzled for a moment. 🙂
May 14, 2010 at 12:45 am
fine, but correct is 'Careful with '
(no rtrim and lower used)
May 14, 2010 at 1:11 am
Really good question, create confusion in mind for the "=" sign used in alias.
May 14, 2010 at 2:48 am
I learnt another thing, thanks to the Question of the day. 🙂
May 14, 2010 at 2:58 am
if flag is alias then can we use next statement like
select [flag='y'].some_data from [where]?
May 14, 2010 at 3:10 am
saranya.megalai (5/14/2010)
if flag is alias then can we use next statement likeselect [flag='y'].some_data from [where]?
No 🙂
I haven't tested it, but the following should work:
select [flag='y'].some_data from [where] [flag='y']
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
May 14, 2010 at 4:27 am
Really interesting and good question. :Wow:
KSB
-----------------------------
Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Knowledge and happiness never decreases by being shared.” - Buddha
May 14, 2010 at 4:56 am
Really its a good question about square brackets.we can use square brackets efficiently at any time.
Malleswarareddy
I.T.Analyst
MCITP(70-451)
May 14, 2010 at 5:04 am
Interesting question, it was the alias that almost caught me out. Have seen plenty of attributes named as reserved words in the past which has caused a few issues unless squared brackets were used. Thinking back I had an interview question once where there was a table called ORDER and the question was what would happen.
May 14, 2010 at 6:04 am
saranya.megalai (5/14/2010)
if flag is alias then can we use next statement likeselect [flag='y'].some_data from [where]?
Yes it would look like:
Select [flag ='y' ].some_data from [where] [flag ='y' ]
Viewing 15 posts - 1 through 15 (of 44 total)
You must be logged in to reply to this topic. Login to reply