I want to Create a table @tablename with data from a User-Defined Table Type but I get the error
Must declare the table variable "@tablename"
ALTER PROCEDURE [dbo].[Prod_EntTable]
@paramEntTable typeTableEnt readonly,
@userid int
AS
BEGIN
Declare @tablename nvarchar(20)
Set @tablename ='mynewtable' + @userid
SELECT EntID, Title INTO @tablename FROM @paramEntTable
END
I tried with EXEC as
EXEC (N'SELECT EntID, Title INTO mynewtable' + @userid + ' FROM ' + @paramEntTable)
the error was
Must declare the table variable "@paramEntTable"
How can this be fixed?
I think, you should edit your code