Couple issues
First, you don't need (name of table)
SET @sql = 'DELETE FROM ' + @TABLE_NAME + etc.
In general you should try to include the appropriate schema prefix
SET @sql = 'DELETE FROM dbo.' + @TABLE_NAME + etc.
And in case your table name has special characters perhaps it should be enclosed in brackets
SET @sql = 'DELETE FROM dbo.[' + @TABLE_NAME + ']' + etc.
Since @Value is a string, you must surround it with single quotes when computing the value for @SQL. To insert a single quote into a string you have to escape it by using two single quotes, like this:
SET @SQL = 'DELETE FROM dbo.[' + @TABLE_NAME + '] WHERE [' + @COLUMN_NAME + '] = '''' + @VALUE + ''''
If @VALUE itself contains a single quote, this whole thing will break, so you need to escape that as well
SET @SQL = 'DELETE FROM dbo.[' + @TABLE_NAME + '] WHERE [' + @COLUMN_NAME + '] = '''' + REPLACE(@VALUE,'''','''''') + ''''
Also, @@ROWCOUNT will not populate from EXEC
. If you want to be able to read @@ROWCOUNT, use sp_ExecuteSQL instead
EXEC sp_ExecuteSql @SQL
And finally, let me editorialize for a minute--
This sort of stored procedure is not a great idea. I know it seems pretty cool because it is flexible, and that kind of thinking is usually smart when it comes to other languages, but in the database world this approach causes problems, e.g. there are security issues (e.g. injection, and the fact that you need elevated privileges to call sp_executeSql) and there issues with precompilation/performance (because the SQL isn't known ahead of time, SQL Server will need to generate a new query plan each and every time you call this) and since the caller can supply any value for table and column name you have no idea whether this delete statement will be efficient and use indexes or if it will cause a huge performance issue because the table is large and the column is not indexed.
The proper approach is to have a series of appropriate stored procedures with strongly-typed inputs that are specific to each data use case where you need to delete based on criteria. Database engineers should not be trying to make things flexible; you should be forcing people to think through what exactly they are going to need, and implement that and only that. That is the only way to ensure people are following the rules, keeping R/I intact, efficient use of indexes, etc.
Yes, this may seem like repetitive and redundant work, but c'est la vie. There are tools available to generate the code for CRUD operations if you don't like the extra typing.