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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to set the value of variable in Select Case

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-10-10 : 03:32:18
Select Case l.GLTransactionTypeID
When 'Asset' --AND l.GLTransactionDate BETWEEN convert(datetime,'1/1/2007')AND convert(datetime,'12/31/2007') and l.GLTransactionSource=@assetID
Then Begin Set @Cost=l.GLtransactionAmount end
end from LedgerTransactions l,FixedAssets f where l.GLtransactionsource=f.assetID and l.GLtransactionsource= @assetID

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-10 : 04:02:25
[code]SELECT @Cost = CASE l.GLTransactionTypeID
WHEN 'Asset' THEN l.GLtransactionAmount
ELSE 0
END
FROM LedgerTransactions AS l
INNER JOIN FixedAssets AS f ON f.assetID = l.GLtransactionsource
WHERE l.GLtransactionsource = @assetID[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -