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 |
|
issam
Starting Member
30 Posts |
Posted - 2007-08-29 : 14:42:29
|
| Hi,I have the following two cursor getting a result table #myresult. the fields ylmdb,ylmcr in table #mycursor is a numeric fields but on the second table become a char with a value of null. How to keep the fields with zero value.declare @bal decimal(19,3)set @bal = 0select year,acctno,sum(lmdb+cmdb) as lydb,sum(lmcr+cmcr) as lycr, @bal as ylmdb,@bal as ylmcrinto #mycursorfrom bmasterwhere year = 2005group by acctno,yearselect acctno,year, ylmdb = (SELECT #mycursor.lydb-#mycursor.lycr WHERE #mycursor.lydb > #mycursor.lycr), ylmcr = (SELECT #mycursor.lycr-#mycursor.lydb WHERE #mycursor.lydb < #mycursor.lycr)into #myresultfrom #mycursororder by acctnoselect * from #myresultthanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-29 : 14:45:42
|
ISNULL(Col1, 0) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-08-29 : 14:45:50
|
| Make use of ISNULL or COALESCE().Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|