Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi!I need to add 1 to every line where the field next to it is not null <> Null.... I am assuming I have to use a case?ThanksAmber
Sachin.Nand
2937 Posts
Posted - 2010-05-29 : 16:45:46
Yes.Here is a test query.
declare @tbl as table(num int,value int)insert into @tblselect 1,null union allselect 1,2 union allselect 5,NULL union allselect 5,5 select num,value,case value when nullif(value,null) then num+1 else num end as newvalue from @tbl