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 2005 Forums
 Transact-SQL (2005)
 Help with CASE syntax

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2010-07-05 : 05:57:09
Hi,

I have this

USE dbPubMatrix
SELECT A.CapId,
ISNULL((select 0),0) as Arval_2,
ISNULL((select CASE WHEN A.capid = 0 THEN 0 ELSE a.price),0) as Arval_3,
ISNULL((select 0),0) as Arval_4
FROM dbPubMatrix..vwtxtmatches A
WHERE A.CapId IN (0,46412,42594,42595,46410,46411,42608,42609)


Line 4 has a syntax error, something wrong with the CASE statement, can anyone help?

Thanks

rocknpop
Posting Yak Master

201 Posts

Posted - 2010-07-05 : 06:12:05
missing END:
CASE......END

--------------------
Rock n Roll with SQL
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-07-05 : 06:20:19
[code]SELECT CapID,
0 AS Arval_2,
CASE CapID
WHEN 0 THEN 0
ELSE ISNULL(Price, 0)
END AS Arval_3,
0 AS Arval_4
FROM dbPubMatrix.dbo.vwTxtMatches
WHERE CapID IN (0, 46412, 42594, 42595, 46410, 46411, 42608, 42609)[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -