I just asked an SQL related question, and the first answer was: “This is a situation where dynamic SQL is the way to go.” As I had never heard of dynamic SQL before, I immediately searched this …
Tag: dynamic-sql
Getting result of dynamic SQL into a variable for sql-server
Executing dynamic SQL as follows in Stored Procedure: How do I use the count(*) column value as return value in the SP? Answer
Why do I get “Procedure expects parameter ‘@statement’ of type ‘ntext/nchar/nvarchar’.” when I try to use sp_executesql?
Why do I get this error Procedure expects parameter ‘@statement’ of type ‘ntext/nchar/nvarchar’. when I try to use sp_executesql? Answer Sounds like you’re calling sp_executesql with a VARCHAR statement, when it needs to be NVARCHAR. e.g. This will give the error because @SQL needs to be NVARCHAR So: