May 23, 2013 at 7:25 am
Hi
In a couple of select statements (out of nine) I had to qualify the field table with the table.
Yet this seems ambiguous in that surely all select statements should be the same.
Any ideas?
May 23, 2013 at 7:31 am
Not entirely sure what you mean. Are you saying you had to qualify a reference to a column with its table/alias name (e.g. "table1.column1") and sometimes you don't (e.g. just "column1")?
If so, that's because it will only throw an error if it's ambiguous. E.g. if you're joining two tables that both have a column called column1, so it couldn't otherwise know which table you were referring to.
It's best practice to always qualify with the table name or alias, even if it isn't ambiguous as there's less chance of a future DDL change breaking existing code.
May 23, 2013 at 9:16 am
Yes
May 23, 2013 at 9:46 am
philip.davy (5/23/2013)
Yes
After reading Howard's explanation do you now understand why that is?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply