-------------DYNAMIC SQL----------------
alter proc emp_ins (@name varchar(100) , @empno int out )
as
begin
declare @query nvarchar(500)=( 'select @i_empno=empno from emp where ename =@in_name ')
exec sp_executesql @query,N'@in_name varchar(100),@i_empno int out' ,@in_name=@name,@i_empno=@ empno out
end
declare @c int
exec emp_ins 'smith',@c out
print @c
No comments:
Post a Comment