For some reasons, I am trying to create a dynamic script to drop tables that I created before. I couldnt do the syntax right and I need help for this matter.
When I run my script, it gives the error:
"Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'."
and this is my script. It has an error in sp_executesql
statement, I guess. How can I fix this?
DECLARE @sql VARCHAR(MAX);
DECLARE @tmpTableName VARCHAR(max);
SET @tmpTableName = '##gmAAA_COLLATION';
SET @sql = 'DROP TABLE @tmpTableName';
EXEC sp_executesql @sql, N'@tmpTableName NVARCHAR(max)', @tmpTableName;