Reputation: 73
Can someone post an example of a stored proc that runs a SQL statement based on parameter?
I have 6 flatfile that are loaded into 6 different staging tables.
Each staging tables requires transformations prior to loading into production table.
Can I create a single spoc that runs specific SQL based on passed in parameter?
For example Exec Sproc_Transform stage_table1
This would run sql statement specific to stage_table1
What is the best approach?
Thanks
Upvotes: 0
Views: 38
Reputation: 873
There is a lot of ways of doing this. To answer your question directly:
create procedure usp_ProcNamehere
@Param1 varchar(10)
as
begin
set nocount on
if @param1='Table1'
begin
select * from table2
update a set id = null from table2
end
else if @param2='Table2'
begin
select * from table2
end
end
Upvotes: 1