i have created a stored procedure and in which i want to set a rowid and table name from select query to a variable but when iam executing my code in sql the bunch of errors are appears
i have decalre a variable but its keep saying to decalare table
heres My code which i have written
USE [DB_A4BA76_logistic]
GO
CREATE PROCEDURE RecoverLogs @id int
AS
declare @TableName nvarchar(50)
declare @RowId int
set @TableName= ( select Logs.tableName from logs where Logs.id=@id)
set @Rowid= ( select Logs.Rowid from logs where id=@id)
Update @TableName set UpdateStatus='0' where id = @Rowid
if(select UpdateStatus from @TableName where id = @Rowid) = '0'
select 1
else
select 2
GO;
and these error are appearing after executing the above code
Msg 1087, Level 16, State 1, Procedure RecoverLogs, Line 7
Must declare the table variable "@TableName".
Msg 1087, Level 16, State 1, Procedure RecoverLogs, Line 8
Must declare the table variable "@TableName".
SELECT....INTOwith a dynamic object, @AmiraBedhiafi?