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 |
|
mrgr8avill
Starting Member
16 Posts |
Posted - 2007-07-21 : 22:30:22
|
| Hello,Another ignorant question, I am sure (I apologize). I have a stored procedure that stores data in to temporary tables, then pulls those tables together in another select, drops the tables, and returns the select.Trouble is, there are some circumstances when I have NULL values, and I really would like to evaluate them to zero.Since the temporary tables being created are both temporary and dynamic, I can't really script their creation (I have to rely on the INSERT INTOs). Is there any way to end up with zeros instead of nulls?Example of SP:select (subquery1 as a, subquery2 as b...) into #temptableoneselect (subquery33 as a, subquery 34 as b...) into #temptable twoselect () #temtableone inner join temptabletwo on about 20 thingsdrop #temptableonedrop #temptabletwoTHANKS!!!!!!!!!!!! |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-07-21 : 23:28:38
|
When you do the SELECT <columnlist> INTO #tmp, use the COALESCE function to return a 0 instead of NULL.SELECT col1, COALESCE(Col2,0), col3INTO #tmp1FROM ... Alternatively, you can do this in your final SELECT too using the same COALESCE function above. Finally, you can do it at your front end too.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
|
|
|
|
|