Im using query analyzer to send results to a file. I have a series of queries that need a variable input.
I want to declare the variable at the top of the page depending on an id. I'm not sure how to get past this point.
Declare @Total int
SET @Total='Select count(*) FROM tbl_A Where ID=3'
exec(@Total)
The exec @Total shows the number I need.
Now I need to grab that number and set it to a variable called @TotR
Then I want to use @TotR in my select queries:
Select Var1/@TotR as 'Divide'
From table1
What am I missing?? I assume it's something easy....
Thanks,
J
I want to declare the variable at the top of the page depending on an id. I'm not sure how to get past this point.
Declare @Total int
SET @Total='Select count(*) FROM tbl_A Where ID=3'
exec(@Total)
The exec @Total shows the number I need.
Now I need to grab that number and set it to a variable called @TotR
Then I want to use @TotR in my select queries:
Select Var1/@TotR as 'Divide'
From table1
What am I missing?? I assume it's something easy....
Thanks,
J