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 |
|
Chinni
Yak Posting Veteran
95 Posts |
Posted - 2008-10-02 : 10:05:11
|
| if income field is blank or null move 0 income field = value move value@income decimal(17,0)set @incomeid = (select income from table)set @income case WHEN (@incomeid IS NULL)THEN 0 WHEN (@incomeid='') THEN 0 ELSE (here i need the query since it has value not null or space)endThanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-02 : 12:09:19
|
| [code]@income decimal(17,0)set @incomeid = (select income from table)SELECT @income= caseWHEN (@incomeid IS NULL)THEN 0WHEN (@incomeid='') THEN 0ELSE fieldENDFROM YourTable[/code] |
 |
|
|
Chinni
Yak Posting Veteran
95 Posts |
Posted - 2008-10-02 : 12:34:26
|
| thanks a lot |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-03 : 02:26:53
|
| <<set @incomeid = (select income from table)>>It would throw error if the query returns more than a value. Use top 1 or max/min if neededMadhivananFailing to plan is Planning to fail |
 |
|
|
Chinni
Yak Posting Veteran
95 Posts |
Posted - 2008-10-03 : 10:05:00
|
| I have a condition likeset @incomeid = (select income from table where id = 1234)SO this may be alright |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-03 : 10:08:45
|
quote: Originally posted by Chinni I have a condition likeset @incomeid = (select income from table where id = 1234)SO this may be alright
only if single record exists for id=1234 |
 |
|
|
|
|
|