I am trying to input different variables into one procedure by just specifying the input parameters - sorry if this is very easy - I have been using SAS for years and trying to figure out SQL!
@VAR is my input parameter. It can either be a number or a text in the data that I am looking at. I want to be able to have say 10 columns that I run this code for and output the results separately by just changing the inputs - is this possible or make sense?
declare @VAR as int???
set @VAR = 'exp_year', 'BusYrsExp'
CREATE PROCEDURE getExpSum @VAR int as
select @VAR, sum(NetCost) as clmCost, sum(claimCount) as clmnum, sum(earneddays) as exposure
into ow_exp_year
from CF_BI
group by @VAR
order by @VAR
OK - if I need to use dynamic sql - can this procedure be used for just one variable? How much more difficult would dynamic sql make this?