August 26, 2009 at 5:53 am
Hi,
I had a question about this script.
select a.name, a.length, b.name
from syscolumns a, sysobjects b
where a.id = b.id
--and a.length > 128
--and a.length < 250 order a.length
select a.name, a.length, b.name
from syscolumns a, sysobjects b
where a.id = b.id
and a.length > 128
and a.length < 250
--order a.length
Mainly, what does the letter "a" or "b" mean in front of the columns?
August 26, 2009 at 6:08 am
to early for homework 😉
it are table aliasses.
a pointing to syscolumns
b pointing to sysobjects
They are only valid for that specific sql statement.
Books online (bol) has more info. http://msdn.microsoft.com/en-us/library/ms187455%28SQL.90%29.aspx
btw I always suggest to use these table aliasses because they will help in query analysis.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
August 26, 2009 at 6:11 am
moyer.mail (8/26/2009)
Hi,I had a question about this script.
select a.name, a.length, b.name
from syscolumns a, sysobjects b
where a.id = b.id
--and a.length > 128
--and a.length 128
and a.length < 250
--order a.length
Mainly, what does the letter "a" or "b" mean in front of the columns?
The letters are referencing the alias used for the tables. A = syscolumns and B = sysobjects. It is often handy to use aliases as it cuts down on the required typing. Another, longer way of saying the same statements as #1 would be:
select syscolumns.name, syscolumns.length, sysobjects.name
from syscolumns, sysobjects
where syscolumns.id = sysobjects.id
Another point in this would be the use of non-ansi joins. Best practice would be to change the statement to use an inner join but this wasn't really your question.
August 26, 2009 at 6:13 am
You guys rock.
Thank you for the quick reply.
J
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply