Phil Murray
Phil Murray

Reputation: 6554

sp_executesql parameter size limit

I have captured a query generated by Entity Framework where one of the parameters can store a large amount (400,000+ characters) of text information in an nvarchar(max) field. The problem I have is that when executing the statement the string is truncated to 43679 characters. This happens if Entity Framework executes the query or if I execute from a query window.

Is there a limit on the size of an entire sp_executesql statement or the size of any individual parameter with the statement?

Table Schema

enter image description here

Generated Query

I have excluded the large string (Markup) for spaces sake.

exec sp_executesql N'INSERT [CDP].[Content]([ProjectId], [Version], [DateAdded], [Owner], [Markup], [State])
VALUES (@0, @1, @2, @3, @4, @5)
SELECT [ContentId]
FROM [CDP].[Content]
WHERE @@ROWCOUNT > 0 AND [ContentId] = scope_identity()',N'@0 int,@1 int,@2 datetime2(7),@3 nvarchar(128),@4 nvarchar(max) ,@5 int',@0=193,@1=0,@2='2015-07-17 12:48:22.1168801',@3=N'<System>',@4=N'[[400000 charater string]]',@5=1

Upvotes: 4

Views: 1099

Answers (1)

Alex K.
Alex K.

Reputation: 175876

Management Studio and most other editors will truncate the display of long text at a certain point, you should verify the length of the inserted data by querying the table it select len(markup) ...

Upvotes: 2

Related Questions