June 5, 2014 at 6:24 am
Great name by the way:-D
Your probably right. Currently I deal with code that's usually less than 200 lines. I guess my preference for space is from years of typing double spaced papers in college.
What is the preference on column aliases ?
,Column1 AS Alias1
OR
,Alias1 = Column1
***SQL born on date Spring 2013:-)
June 5, 2014 at 6:26 am
I prefer the alias with the equal sign. It is very easy to align everything, especially when you have larger expressions.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 5, 2014 at 6:36 am
Koen Verbeeck (6/5/2014)
I think this thread sums up the general feeling towards code formatting displayed in this thread.http://www.sqlservercentral.com/Forums/Topic1577630-391-1.aspx
There is soap behind the counter to wash your eyes with...
Gah.... :crying:
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 5, 2014 at 6:46 am
thomashohner (6/5/2014)
What is the preference on column aliases ?
AS. Equals sign is for comparing values or assigning values. 😀
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 5, 2014 at 6:50 am
GilaMonster (6/5/2014)
thomashohner (6/5/2014)
What is the preference on column aliases ?AS. Equals sign is for comparing values or assigning values. 😀
Yes, you assign the result of the expression to a column. 😉
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 5, 2014 at 6:53 am
Koen Verbeeck (6/5/2014)
GilaMonster (6/5/2014)
thomashohner (6/5/2014)
What is the preference on column aliases ?AS. Equals sign is for comparing values or assigning values. 😀
Yes, you assign the result of the expression to a column. 😉
No, I'm renaming the result of the expression, giving it another name that is it known AS. 😎
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 5, 2014 at 6:55 am
GilaMonster (6/5/2014)
Koen Verbeeck (6/5/2014)
GilaMonster (6/5/2014)
thomashohner (6/5/2014)
What is the preference on column aliases ?AS. Equals sign is for comparing values or assigning values. 😀
Yes, you assign the result of the expression to a column. 😉
No, I'm renaming the result of the expression, giving it another name that is it known AS. 😎
Potayto, potahto 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 5, 2014 at 7:14 am
GilaMonster (6/5/2014)
Koen Verbeeck (6/5/2014)
GilaMonster (6/5/2014)
thomashohner (6/5/2014)
What is the preference on column aliases ?AS. Equals sign is for comparing values or assigning values. 😀
Yes, you assign the result of the expression to a column. 😉
No, I'm renaming the result of the expression, giving it another name that is it known AS. 😎
I agree with Gail here, use AS not =.
If I knew there was only one blank line between the code, maybe I could be on board with that. I've just been bitten may times when trying to run someone else's code and I go to highlight what I want to run, only to find out there are more joins, or a group by I missed because there are one or more blank lines, this usually happens when there are 2 or more blank lines between.
-------------------------------------------------------------
we travel not to escape life but for life not to escape us
Don't fear failure, fear regret.
June 5, 2014 at 7:38 am
GilaMonster (6/5/2014)
Koen Verbeeck (6/5/2014)
GilaMonster (6/5/2014)
thomashohner (6/5/2014)
What is the preference on column aliases ?AS. Equals sign is for comparing values or assigning values. 😀
Yes, you assign the result of the expression to a column. 😉
No, I'm renaming the result of the expression, giving it another name that is it known AS. 😎
I prefer AS AS well. = is <> aliAS ASsignment imho.
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
June 5, 2014 at 7:42 am
SQLRNNR (6/5/2014)
GilaMonster (6/5/2014)
Koen Verbeeck (6/5/2014)
GilaMonster (6/5/2014)
thomashohner (6/5/2014)
What is the preference on column aliases ?AS. Equals sign is for comparing values or assigning values. 😀
Yes, you assign the result of the expression to a column. 😉
No, I'm renaming the result of the expression, giving it another name that is it known AS. 😎
I prefer AS AS well. = is <> aliAS ASsignment imho.
= is an ASsignment operator 😛
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 5, 2014 at 7:45 am
On the subject of WITH (NOLOCK) in code being a pet peeve....
I was going over an SSIS template with a consultant the other day, and there was WITH (NOLOCK) all over the place in his Execute SQL tasks. I asked him why and he said "It is an industry standard."
I told him it wasn't. He said "The first place I worked, it was required to use it on every query and I have used it everywhere ever since and nobody has said not to."
I responded that that doesn't make it an industry standard, as the first guy who told him to do that was wrong.
He shrugged and said he wasn't going to change it. His defense is "we must prevent deadlocks."
June 5, 2014 at 7:48 am
SQL is delicious (6/5/2014)
On the subject of WITH (NOLOCK) in code being a pet peeve....I was going over an SSIS template with a consultant the other day, and there was WITH (NOLOCK) all over the place in his Execute SQL tasks. I asked him why and he said "It is an industry standard."
I told him it wasn't. He said "The first place I worked, it was required to use it on every query and I have used it everywhere ever since and nobody has said not to."
I responded that that doesn't make it an industry standard, as the first guy who told him to do that was wrong.
He shrugged and said he wasn't going to change it. His defense is "we must prevent deadlocks."
I seeing something similar, My Developer friend says he never used it before but was told he had to on a code review.
***SQL born on date Spring 2013:-)
June 5, 2014 at 7:49 am
SQL is delicious (6/5/2014)
On the subject of WITH (NOLOCK) in code being a pet peeve....I was going over an SSIS template with a consultant the other day, and there was WITH (NOLOCK) all over the place in his Execute SQL tasks. I asked him why and he said "It is an industry standard."
I told him it wasn't. He said "The first place I worked, it was required to use it on every query and I have used it everywhere ever since and nobody has said not to."
I responded that that doesn't make it an industry standard, as the first guy who told him to do that was wrong.
He shrugged and said he wasn't going to change it. His defense is "we must prevent deadlocks."
Your response is:
"and you want dirty data"...
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 5, 2014 at 7:53 am
Koen Verbeeck (6/5/2014)
SQL is delicious (6/5/2014)
On the subject of WITH (NOLOCK) in code being a pet peeve....I was going over an SSIS template with a consultant the other day, and there was WITH (NOLOCK) all over the place in his Execute SQL tasks. I asked him why and he said "It is an industry standard."
I told him it wasn't. He said "The first place I worked, it was required to use it on every query and I have used it everywhere ever since and nobody has said not to."
I responded that that doesn't make it an industry standard, as the first guy who told him to do that was wrong.
He shrugged and said he wasn't going to change it. His defense is "we must prevent deadlocks."
Your response is:
"and you want dirty data"...
Correct, and that is exactly what I said to him. He shrugged and said it didn't matter.
I should add that this (foreign) consultant, while reasonably friendly, also labors under the delusion that the American education system is worthless and that our master's level work is the equivalent of junior high/early high school material in India. Given his assumption, he is dismissive of Americans' concerns. I don't think he does it on purpose, or to be mean...I just think there is an innate cultural bias at work that he may not even be aware of.
What this means is I not only have to prove that he's wrong, but provide an alternative strategy. I'm working on that now, but if anyone has any ideas I'd love to hear them. 😉
June 5, 2014 at 8:10 am
SQL is delicious (6/5/2014)
Koen Verbeeck (6/5/2014)
SQL is delicious (6/5/2014)
On the subject of WITH (NOLOCK) in code being a pet peeve....I was going over an SSIS template with a consultant the other day, and there was WITH (NOLOCK) all over the place in his Execute SQL tasks. I asked him why and he said "It is an industry standard."
I told him it wasn't. He said "The first place I worked, it was required to use it on every query and I have used it everywhere ever since and nobody has said not to."
I responded that that doesn't make it an industry standard, as the first guy who told him to do that was wrong.
He shrugged and said he wasn't going to change it. His defense is "we must prevent deadlocks."
Your response is:
"and you want dirty data"...
Correct, and that is exactly what I said to him. He shrugged and said it didn't matter.
I should add that this (foreign) consultant, while reasonably friendly, also labors under the delusion that the American education system is worthless and that our master's level work is the equivalent of junior high/early high school material in India. Given his assumption, he is dismissive of Americans' concerns. I don't think he does it on purpose, or to be mean...I just think there is an innate cultural bias at work that he may not even be aware of.
What this means is I not only have to prove that he's wrong, but provide an alternative strategy. I'm working on that now, but if anyone has any ideas I'd love to hear them. 😉
Great. I love that excuse "It's the way we/I have always done it".
That kind of excuse right there shows a base incompetence. Everything he needed to learn was learned in kindergarten.
He is using nolock therefore it would be apparent that he is creating a lot of crap code. Yup, that is highly educated.:-D
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
Viewing 15 posts - 76 through 90 (of 272 total)
You must be logged in to reply to this topic. Login to reply