sql server - How to prompt an SQL query user to input information -


i have query wrote in sql server run people don't know sql, , there 2 areas have have different string or date entered each time query run. of right now, wrote enter information @ top of query , stored variable. there way can sql prompt person running query enter data? below excerpt of code has talking in it.

declare  /*enter accounting month*/         @amon varchar(2) = '05', /*enter invoice date in mm/dd/yyyy format*/    @invdate date = '05/31/2015' ~~ rest of code ~~ declare @suma numeric(25, 5), @sumb numeric(25, 5), @ratio numeric(25, 5) select @suma = sum(amnt) accnt accno = '1152' select @sumb = sum(amnt) acc1152 update acc1152 set amnt = amnt * (@suma/@sumb), amon = @amon, invdate = @invdate, ven = '1152', code = '1152', invno = 'inventory' 

so possible sql prompt user type in value @amon , @invdate? other me having comment line telling them so?

in case can not application, have no developers etc etc, have 1 way - make stored proc:

create stored procedure spdosomejob @amon varchar(2), @invdate date begin      ~~     rest of code     ~~     declare @suma numeric(25, 5), @sumb numeric(25, 5), @ratio numeric(25, 5)     select @suma = sum(amnt) accnt accno = '1152'     select @sumb = sum(amnt) acc1152     update acc1152 set amnt = amnt * (@suma/@sumb),     amon = @amon,     invdate = @invdate,     ven = '1152',     code = '1152',     invno = 'inventory'  end 

deny activity permissions users except running procedure. execute like:

exec spdosomejob  @amon = '05', @invdate = '05/31/2015' 

at least sure no user can corrupt something... , if not supply values parameters of stored procedure prompt unless have no default values parameters. seems me best workaround case.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -