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)
 Need Help with the Query

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2011-02-14 : 11:29:33
I have a query where I join two tables and return the result. One of the tables have a field called IsDefault. I want to get when the Isdefault = 1 in the DefaultTask column and then isDefault = 0 into the Task column. How an I do that?

Mohammad Azam
www.azamsharp.net

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-14 : 12:06:42
Defaulttask = Case When isDefault = 1 then IsDEfault else null end,
Task = Case When isDefault = 0 then IsDefault else null end


OR
Defaulttask = NULLIF(isDefault,1)
Task = NULLIF(isDefault,0)



Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page
   

- Advertisement -