title: How to Create DELETE Statement Stored Procedure Using TableName, ColumnName, and ColumnValue as Passing Parameters
body: <p>Here is what i'm trying to do. I'm trying to create a stored procedure where I could just enter the name of the table, column, and column value and it will delete any records associated with that value in that table. Is there a simple way to do this? I don't know too much about SQL and still learning about it.</p>
  
  <p>Here is what I have so far. </p>
  
  <pre><code>ALTER PROCEDURE [dbo].[name of stored procedure] 
  @TABLE_NAME varchar(50),
  @COLUMN_NAME varchar(50),
  @VALUE varchar(5)
  
  AS
  BEGIN
      SET NOCOUNT ON;
  
      DECLARE @RowsDeleted int;
      DECLARE @sql VARCHAR(500);
  
      SET @sql = 'DELETE FROM (name of table).' + @TABLE_NAME + ' WHERE ' + @COLUMN_NAME + '=' + '@VALUE'
      EXEC(@sql)
  
      SET @RowsDeleted=@@ROWCOUNT
  END
  GO
  </code></pre>