update productions set countrycode = (case when @soffice='la' or @soffice='ga' 'usa' else 'can' end)
can confirm if correct update case statement. seem running error of sort. seems correct me.
i working on application , have update statment:
sqlcommand cmd = new sqlcommand("update productions set countrycode = (case when @soffice in ('la', 'ga') 'usa' else 'can' end), provincecode = '" + user.getprovincecode() + "' id = " + newproductionid, conn); cmd.executenonquery();
but when build application , run functionality following error:
exception message: must declare scalar variable "@soffice". exception triggered method: onerror
what mean??
declare @productions table( ind int not null identity(1,1)primary key clustered ,countrycode nchar(3) not null ,soffice nchar(2) null ) insert @productions (countrycode, soffice) values ('ita','la') insert @productions (countrycode, soffice) values ('ita','ve') insert @productions (countrycode, soffice) values ('ita','lz') insert @productions (countrycode, soffice) values ('fra','ga') insert @productions (countrycode, soffice) values ('fra','bf') insert @productions (countrycode, soffice) values ('ita','vr') insert @productions (countrycode, soffice) values ('ger','la') insert @productions (countrycode, soffice) values ('can','la') select * @productions update p set countrycode = case p.soffice when 'la' 'usa' when 'ga' 'usa' else 'can' end -- case @productions p select * @productions
copy , paste code above on sql server 2008 , see works fine.
hope helps marcelo
Comments
Post a Comment