Why does SQL Server query works differently on different servers? -


i have query behaving differently when run against 2 databases.

i have copied staging database locally , using debug code.

here's query :

select distinct ........, acs.lastname bs.name branchname, ..... ...... ...... ) left join companytrove  bs on ......................... ............................ order acs.lastname,bs.branchname, ..... asc 

companytrove table has no column called branchname. so, fails on local copy of database. when run same query against actual database runs fine though companytrove table on database not have branchname column (it same table of course).

any ideas on missing ?

see

behaviour changes database engine features in sql server 2005

specifically order clause section.

the sql server 2000 behaviour

column names in order clause resolved columns listed in select list, regardless if qualified. example, following query executes without error:

use pubs select au_fname 'fname',   au_lname 'lname' authors order a.lname 

sql server ignores qualifier in order clause , resolves column name lname select list.

so presume trying on database in 2000 compatibility mode when worked without complaint.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo