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.
Author |
Topic |
usafelix
Posting Yak Master
165 Posts |
Posted - 2015-01-30 : 02:52:01
|
Dear Sir,i have two field column and want to write this query. how to do ?select temp_staff, per_staff,if temp_Staff<>'' and per_staff='' then copy temp_staff to per_staff copy space to temp_staffendamount,totalfrom test |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-01-30 : 07:21:05
|
Look up the CASE expression |
|
|
usafelix
Posting Yak Master
165 Posts |
Posted - 2015-02-02 : 05:09:49
|
pls direct edit my query . help |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-02 : 07:04:57
|
Try it on your own first using a case expression |
|
|
pradeepbliss
Starting Member
28 Posts |
Posted - 2015-02-05 : 03:57:50
|
quote: Originally posted by usafelix Dear Sir,i have two field column and want to write this query. how to do ?select temp_staff, per_staff,if temp_Staff<>'' and per_staff='' then copy temp_staff to per_staff copy space to temp_staffendamount,totalfrom test
Simple Update query without using caseupdate s set s.temp_staff=s.per_staff,s.per_staff=s.temp_staff from test s where temp_Staff <>'' and per_staff='' update s set s.per_staff=s.temp_staff,s.temp_staff=s.per_staff from test s where temp_Staff = '' and per_staff <>'' |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-02-05 : 09:49:31
|
@pradeepblissThe OP never said he wanted to updated the data! |
|
|
|
|
|