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 |
|
gaauspawcscwcj
Starting Member
29 Posts |
Posted - 2009-12-02 : 01:03:19
|
| hi alli have to get data in A table. if can not get it ( data is not exist in this table) --> set data by input data.table A : item1 item2input data : item3--> select item1 from A where item2 = item3. if result of this query is nothing --> set item1 = item3here is my query : SELECT CASE WHEN @@ROWCOUNT = 0 THEN 'item3' ELSE item1 ENDFROM A WHERE item2 = 'item3'the result is nothing.i had tried ISNULL but its not worked :(nay ideas for helping methanksgaauspawcscwcj |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-02 : 01:26:03
|
| Try thisselect top 1 case when(select count(*) from A where item2 = 'item3') >0 then item1 else 'item3' endas data from ASenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-02 : 01:44:34
|
| declare @item varchar(20)set @item=(select max(item1) from A where item2 = 'item3')select coalesce(@item,'item3')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|