Hi
I'm trying to delete a record from a table in SQL Server using a store procedure. The table name, column and record id are parameters being passed in. I don't want to hard code the table name, column or record, as this store procedure will be used for many tables , columns and records that will be deleted.
This is what I have so far:
CREATE PROCEDURE procDeleteMaintenanceRecord
@recordID int -- the record to be deleted
@tablesName varchar(50) -- the table where the record will be deleted from
@columnName varchar(50) -- the column name where the record will be deleted from
AS
DELETE FROM @tablesName = syscolumns.object_name(id)
WHERE @columnName = @recordID
GO
It doesn't work. Does anyone have any idea on how to do this. Thanks in advance
I'm trying to delete a record from a table in SQL Server using a store procedure. The table name, column and record id are parameters being passed in. I don't want to hard code the table name, column or record, as this store procedure will be used for many tables , columns and records that will be deleted.
This is what I have so far:
CREATE PROCEDURE procDeleteMaintenanceRecord
@recordID int -- the record to be deleted
@tablesName varchar(50) -- the table where the record will be deleted from
@columnName varchar(50) -- the column name where the record will be deleted from
AS
DELETE FROM @tablesName = syscolumns.object_name(id)
WHERE @columnName = @recordID
GO
It doesn't work. Does anyone have any idea on how to do this. Thanks in advance