PreacherUK
Technical User
hi all,
I have a table/view (at this stage I'm running it as a view but figure I can make it a temp table in an sp) which is subtracting one field from another.
This will result in a value that, will hopefully be zero, give or take a tolerance of $5 in either direction.
Whats the best way of making a decision based on the result of that view/content of the table?
Ask the view to return to me all records that dont have a zero balance and check for that with the @@ROWCOUNT key word?
Or should I be using some code/logic along the line of IF (view returns nothing) then etc?
I've included the view here (for what its worth
)
SELECT [OnLoan$From Stats] - [OnLoan$From Source] AS Onloan, [Accrued$From Stats] - [Accrued$From Source] AS Accrued
FROM dbo.TMPTABLECOMPARE
WHERE ([OnLoan$From Stats] - [OnLoan$From Source] > 5) AND ([Accrued$From Stats] - [Accrued$From Source] > 5)
OR ([OnLoan$From Stats] - [OnLoan$From Source] < - 5)
AND ([Accrued$From Stats] - [Accrued$From Source] < - 5)
Cheers
I have a table/view (at this stage I'm running it as a view but figure I can make it a temp table in an sp) which is subtracting one field from another.
This will result in a value that, will hopefully be zero, give or take a tolerance of $5 in either direction.
Whats the best way of making a decision based on the result of that view/content of the table?
Ask the view to return to me all records that dont have a zero balance and check for that with the @@ROWCOUNT key word?
Or should I be using some code/logic along the line of IF (view returns nothing) then etc?
I've included the view here (for what its worth
SELECT [OnLoan$From Stats] - [OnLoan$From Source] AS Onloan, [Accrued$From Stats] - [Accrued$From Source] AS Accrued
FROM dbo.TMPTABLECOMPARE
WHERE ([OnLoan$From Stats] - [OnLoan$From Source] > 5) AND ([Accrued$From Stats] - [Accrued$From Source] > 5)
OR ([OnLoan$From Stats] - [OnLoan$From Source] < - 5)
AND ([Accrued$From Stats] - [Accrued$From Source] < - 5)
Cheers