Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 CASE Statement help, is this possible?

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2005-10-18 : 11:42:21
Is this possible to do with a case statement? I'm getting an error. Incorrect syntax near the keyword select.

SELECT CASE WHEN dbo.MBA4CPP.A4AGPC IS NULL THEN
SELECT dbo.MBA4CPP.A4AGPC
FROM dbo.MBC6REP INNER JOIN
dbo.MBA3REP ON dbo.MBC6REP.C6F2CD = dbo.MBA3REP.A3F2CD INNER JOIN
dbo.MBA4CPP ON dbo.MBA3REP.A3F2CD = dbo.MBA4CPP.A4F2CD
WHERE (dbo.MBC6REP.C6CVNB = ' 295308') ELSE dbo.MBA4CPP.A4AGPC END
FROM dbo.MBA3REP INNER JOIN
dbo.MBA4CPP ON dbo.MBA3REP.A3F2CD = dbo.MBA4CPP.A4F2CD RIGHT OUTER JOIN
dbo.MBCDREP ON dbo.MBA4CPP.A4F2CD = dbo.MBCDREP.CDF2CD
WHERE (dbo.MBCDREP.CDCVNB = 295308)

Hommer
Aged Yak Warrior

808 Posts

Posted - 2005-10-18 : 11:46:23
Try this:
SELECT CASE dbo.MBA4CPP.A4AGPC WHEN NULL THEN...
or

SELECT CASE isNull(dbo.MBA4CPP.A4AGPC) WHEN true THEN...
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-18 : 12:18:20
Something like this perhaps?

IF EXISTS (SELECT * FROM dbo.MBC6REP JOIN ... WHERE ... AND dbo.MBA4CPP.A4AGPC IS NULL)
BEGIN
SELECT dbo.MBA4CPP.A4AGPC
FROM dbo.MBC6REP
INNER JOIN ...
END

Kristen
Go to Top of Page
   

- Advertisement -