I would like to execute dynamic SQL statements which are about 10,000 characters.
When I use sp_executesql as below:
DECLARE @stmt varchar(MAX)
SET @stmt = 'xxxxxxxx.................' which is about 10,000 characters
EXEC sp_executesql @stmt
I got the following error
The character string that starts with ' select t1.e_reference xxxxxxxxxxx' is too long. Maximum length is 8000.
As far as I know, we can use sp_executesql to execute very long statements, can't we?
I am using SQL Server 2008, Enterprise Edition, 64 bit.
How can I achieve this? Thanks.
sys.messages
. Are you querying a linked server?