Home > Archive > MS SQL Server > December 2006 > Query works in 2000 but not 2005









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Query works in 2000 but not 2005
adauti@gmail.com

2006-12-13, 7:12 pm

I noticed that some queries work in 2000, but not in 2005, for example


SELECT columnA,
columnB,
case when columnC = 'BLAH' then dbo.fn_func(columnD)
sum(columnE)
FROM TableA
GROUP BY
columnA,
columnB,
case when columnC = 'BLAH' then dbo.fn_func(columnD)

Works for 2K, but for 2K5 i get an error message saying "columnD is
invalid in the select list because it is not contained...etc etc"

ANyone know of the change?

Linchi Shea

2006-12-14, 12:12 am

It shouldn't work on SQL2000 either. Your CASE expression is not complete and
there should be a comma before sum(columnE).

The following should work on both versions:

SELECT columnA,
columnB,
case when columnC = 'BLAH' then dbo.fn_func(columnD) end,
sum(columnE)
FROM TableA
GROUP BY
columnA,
columnB,
case when columnC = 'BLAH' then dbo.fn_func(columnD) end

Linchi

"adauti@gmail.com" wrote:

> I noticed that some queries work in 2000, but not in 2005, for example
>
>
> SELECT columnA,
> columnB,
> case when columnC = 'BLAH' then dbo.fn_func(columnD)
> sum(columnE)
> FROM TableA
> GROUP BY
> columnA,
> columnB,
> case when columnC = 'BLAH' then dbo.fn_func(columnD)
>
> Works for 2K, but for 2K5 i get an error message saying "columnD is
> invalid in the select list because it is not contained...etc etc"
>
> ANyone know of the change?
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com