I have a question, can we pass table name as input parameter to store procedure.
The answer is yes we can.
However, can we use this table name in the join condition for example&.
I have two tables Product_data and Inventory. I want to pass Product_data as input parameter to store procedure and in WHERE clause join the product_data and Inventory table on id
(product_data.id = inventory.id ).
Create procedure DeleteFromDataTables @product_name varchar(50)
DECLARE @table_name varchar(50)
select @table_name = @product_name + "_data"
declare @sqlstring varchar(2000)
select @sqlstring = "DELETE from "
+ "where @table_name.id = Inventory.id" +