I am trying to create a stored procedure for inserting new data. Basically I am getting an error about \'declare the table variable@tablename\'.
I tried:
Prepare dynamic insert statement as below:
CREATE procedure [dbo].[spInsertProc](@table_name varchar(max))
as
begin
declare @name varchar(50)='Sandip';
declare @description varchar(50)='SE';
Declare @Query VARCHAR(MAX)
SET @Query='Insert Into '+@table_name+' ([name], [description])
Values (
'''+@name+''',
'''+@description+''')'
EXEC(@Query);
PRINT(@Query);
end