select @amount=tax_amnt from @tblnm where @trn_col_nm=@trn_No and tax_nm=@taxnm
use "exec" function this way dec @myamt varchar(20); exec(' declare @amount decimal(12,3); set @amount='+@myamt+' select @amount=tax_amnt from @tblnm where @trn_col_nm=@trn_No and tax_nm=@taxnm')
Execute a stored procedure or function [ { EXEC | EXECUTE } ] { [ @return_status = ] { module_name [ ;number ] | @module_name_var } [ [ @parameter = ] { value | @variable [ OUTPUT ] | [ DEFAULT ] } ] [ ,...n ] [ WITH RECOMPILE ] } [;]; Execute a character string { EXEC | EXECUTE } ( { @string_variable | [ N ]'tsql_string' } [ + ...n ] ) [ AS { LOGIN | USER } = ' name ' ] [;]; Execute a pass-through command against a linked server { EXEC | EXECUTE } ( { @string_variable | [ N ] 'command_string [ ? ]' } [ + ...n ] [ { , { value | @variable [ OUTPUT ] } } [ ...n ] ] ) [ AS { LOGIN | USER } = ' name ' ] [ AT linked_server_name ] [;];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)