Looking for solution in case statement in SQL Server -
i trying write below statements in case statements. trying update value in 1 different tableb particular column.
after
update set dismmr = then trying check below condition in case statements
'h01' not null , ('h02','h03','hr04','s07','s08','s09') null 'unknown' here values table name : tablea , column name code.
this particular column designed not null
here is null means trying that, particular value ('h02','h03','hr04','s07','s08','s09') don't exist or present in tablea.
when particular value h01 in tablea column code ---- is not null -- means particular value of column code exist/present in column tablea.
i need 1 in case statements because once done checking condition , writing other case statements started when check condition , update different value
i using sql server 2008 r2. wrote below query. runs fine in ssms when use store procedure in ssis package. package fails error.
[execute sql task] error: executing query "execute [dbo].[usp_getmrf_chp] ?,?,?" failed following error: "only 1 expression can specified in select list when subquery not introduced exists.". possible failure reasons: problems query, "resultset" property not set correctly, parameters not set correctly
case when exists(select 1 dbo.tablea code = 'h01') , not exists(select 1 dbo.tablea code in ('h02','h03','hr04','s07','s08','s09') ) 'unknown' when ---- have case here. any appreciated. in advance
if understand correct want know if record code = 'h01' exists while no record other codes exist. case statement this:
case when exists(select 1 dbo.tablea code = 'h01') , not exists(select 1 dbo.tablea code in ('h02','h03','hr04','s07','s08','s09') ) 'unknown' end
Comments
Post a Comment