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 |
|
stovellp
Starting Member
1 Post |
Posted - 2004-10-03 : 09:10:31
|
I have the following line in an SQL Server stored procedure:SELECT @SumDR = SUM([Value]) FROM DebtorEntries WHERE [DebtorID]=@debtorID AND [Type]='DR' AND [Date] BETWEEN @startDate AND @endDate It works fine when it finds matches to sum the Value column up, but when there are no matches I cannot access the value of @SumDR. I can't print it, it's not NULL and it's not 0. But I can assign new values to it.Is there a way I can change the query or add something under it to set @SumDR = 0 if it wasn't set (without having to re-query the database)?And when the game is over, the king and the pawn both go back into the same box. |
|
|
VIG
Yak Posting Veteran
86 Posts |
Posted - 2004-10-03 : 12:13:26
|
| SELECT @SumDR = isnull(SUM([Value]),0) FROM DebtorEntries WHERE [DebtorID]=@debtorID AND [Type]='DR' AND [Date] BETWEEN @startDate AND @endDate |
 |
|
|
|
|
|