If we pass table name as parameter to the stored procedure , we can use single stored procedure for different tables which contains same column names and data types. For this follow the stored procedure below
create procedure Test(@table_name varchar(max))
as
declare @va varchar(max)
begin
set @va = 'select * from ' + @table_name
EXEC(@va)
RETURN
end
create procedure Test(@table_name varchar(max))
as
declare @va varchar(max)
begin
set @va = 'select * from ' + @table_name
EXEC(@va)
RETURN
end
No comments:
Post a Comment