After Work
Old Town Social
in Chicago, on North Ave, near Cleveland. Great selection of tap beers.
Kyoto Sushi
in Chicago, on Lincoln Ave.
Moody's Pub
in Chicago, has great burgers
Skylark
in Chicago, on Halsted .. excellent beer selection!
|
Sybase
»
T-SQL
»
Coding
»
Executing dynamic SQL in a procedure
In many cases, it is necessary to derive the column name of a query at runtime.
Here's how to do that, in a compiled stored procedure. Note that this is a good method
to use when you want the optimizer to re-process your query at every execution.
-- executing dynamic SQL, in a stored proc
declare @sqlcmd varchar(999),
@monthcolumn varchar(30)
select @monthcolumn = 'sept_sales'
select @sqlcmd =
'update sales_report set ' + @monthcolumn + ' = 5200 ' +
'where salesrep_id = 25 '
execute (@sqlcmd)
if @@error > 0
raiserror 99999 'Error ocurred during report dynamic SQL exec'
|
|
|
Get the latest Rocket99 news and tech tips via
|