I'm trying to pass table and column name to a stored procedure (I have several tables with the same basic structure). Here's what I tried:
CREATE PROCEDURE del_loc
(
@table_name varchar(50),
@col_name varchar(50),
@id_to_del int
)
AS
DELETE @table_name
where (@col_name = @id_to_del)
SQL will not let me add this procedure. Since it is looking for the actual table name, it bombs on the DELETE @table_name. Is there any way to do this with SQL or will I be forced to create a stored procedure for each individual table? [sig][/sig]
CREATE PROCEDURE del_loc
(
@table_name varchar(50),
@col_name varchar(50),
@id_to_del int
)
AS
DELETE @table_name
where (@col_name = @id_to_del)
SQL will not let me add this procedure. Since it is looking for the actual table name, it bombs on the DELETE @table_name. Is there any way to do this with SQL or will I be forced to create a stored procedure for each individual table? [sig][/sig]