By creating a dynamic sql statement you will be able to build and run the query at runtime.
This should do the trick. First run the stored procedure and check the output from the
print
command. When you are confident that all is okay, comment out the print command and uncomment the
exec
command:
ALTER PROCEDURE [dbo].[Del_Users]
@UserID int,
@Table_name nvarcher(50)
AS
BEGIN
declare @cmd nvarchar(max) = ''
set @cmd += N' DELETE FROM ' + @Table_name + ' where UserID = ' @UserID
print @cmd
--exec sys.sp_executesql @cmd
END