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 |
|
lucsky8
Posting Yak Master
105 Posts |
Posted - 2008-06-03 : 08:25:21
|
| Hi, i am using stored procedure with sql server 2005.I have this tabletblReponseintReponseId [autonumber]strNameintT2intT3Here some data1 Luc A B2 Marc C D3 John A 4 Kev A D5 Pual A I need to create a query that will take intT3 if there something in intT3 but if intT3 is empty take intT2 instead.So for this data it will give me this:B D A D AAny idea thanks in advance!! |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-06-03 : 08:27:56
|
By empty do you mean it is null?Select coalesce(intT3, intT2)from table Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-03 : 08:28:04
|
| SELECT COALESCE(NULLIF(intT3,' '),intT2) FROM tblResponse |
 |
|
|
lucsky8
Posting Yak Master
105 Posts |
Posted - 2008-06-03 : 08:31:33
|
| Hi tks for the quick reply i mean empty not NULLAND for SELECT COALESCE(NULLIF(intT3,' '),intT2) FROM tblResponse i will try it wright away!I let know thanks! |
 |
|
|
lucsky8
Posting Yak Master
105 Posts |
Posted - 2008-06-03 : 08:34:11
|
| Hi tks for your anwser that work perfectlySELECT COALESCE(NULLIF(intT3,' '),intT2) FROM tblResponseMany tks !!!!!!I learn something COALESCE that nice |
 |
|
|
|
|
|