Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Using variables in an IF statement? Expand / Collapse
Author
Message
Posted Thursday, March 07, 2013 12:47 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, March 21, 2013 8:06 AM
Points: 21, Visits: 48
Chrissy,

Thanks so much for all your help. Using the IF statements worked. I built it down to be a little more concise just using Boolean logic

Begin

declare @idnum varchar
select @idnum = 1
declare @TC varchar(50)
select @TC = 'all'


select B.GroupDetail, C.SecID, C.TransCode, C.Quantity, B.GroupId, C.PortfolioID
FROM ERTutTransactions C
INNER JOIN FinalGroupDetail B
ON C.PortfolioID = B.PortfolioID
AND B.GroupId = @idnum
WHERE
@TC = 'ALL'
OR
( @TC IN ('BUY','SELL') AND TransCode = @TC )
END
Post #1428203
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse