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)
 error in case statement

Author  Topic 

skybvi
Posting Yak Master

193 Posts

Posted - 2011-04-05 : 16:30:45
Hi,
I am running this code:-


DECLARE @tab TABLE
(
upc NVARCHAR(20),
ITEMNMBR NVARCHAR(20),
DESCRIPTION NVARCHAR(200),
QTY_SOLD FLOAT,
SALES_AMOUNT FLOAT,
PRIMVNDR CHAR(15),
VENDOR_NAME CHAR(65)
)

INSERT @tab
(
upc,
ITEMNMBR,
DESCRIPTION,
QTY_SOLD,
SALES_AMOUNT,
PRIMVNDR,
VENDOR_NAME
)
SELECT
*
FROM
ff_2

UPDATE @tab
SET t.itemnmbr=a.itemnmbr

FROM @tab t
join EP40101 a
on a.itemupccode = t.upc

UPDATE @tab
SET itemnmbr =
case
when (itemnmbr <> b.itemnmbr)
itemnmbr = 'NULL'
ELSE itemnmbr
end

from @tab t
join dbo.IV00101 b
on t.itemnmbr= b.itemnmbr

select * from @tab

--AND IAM GETTING THIS ERROR:-

Msg 102, Level 15, State 1, Line 39
Incorrect syntax near 'itemnmbr'.



Regards,
Sushant
DBA
West Indies

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-05 : 16:44:33
case
when (itemnmbr <> b.itemnmbr) then NULL
ELSE itemnmbr
end

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

skybvi
Posting Yak Master

193 Posts

Posted - 2011-04-06 : 09:44:08
yes, the syntax error went but i didnt get the result as I wanted.

I thought it would replace the column value of that itemnmbr as NULL,
but its the same :(


Regards,
Sushant
DBA
West Indies
Go to Top of Page
   

- Advertisement -