I have a stored procedure where a SQL string is built depending on a bunch of input parameters. When the SQL is built, it is executed with sp_executesql. However, now I have a situation that the SQL becomes very large. I made the variable @SqlString varchar(8000) instead of nvarchar(4000), but it still doesn't work. I'm suspecting that sp_executesql can't handle a string larger than 4000. Can anyone confirm this and help me with a solution for this problem?