If the stored proc does any string manipulation of the variable @wnotes it may get truncated.
What's the biggest size of string I can use with SqlDbType?
I'm using C# with ASP.NET, where the codebehind uses a string named wnotes with about 9500 bytes long. (string wnotes = "...")
When I call a stored proc, I pass the string this way:
spCommand.Parameters.Add("@wnotes", SqlDbType.VarChar, -1).Value = wnotes;
In the stored proc, it receives wnotes as:
declare @wnotes varchar(max)
But after processing, I only see about 4000 get into the database.
Any thoughts?
Developer technologies | ASP.NET | Other
-
Bruce (SqlWork.com) 81,981 Reputation points Volunteer Moderator
2021-08-21T15:22:56.8+00:00
3 additional answers
Sort by: Most helpful
-
Ravi Kakarla 161 Reputation points
2021-08-21T14:46:15.973+00:00 If wnotes column data type is defined as either VARCHAR(MAX) or NVARCHAR(MAX), you should store more than 9500 bytes. Can you please share confirm wnotes column datatype?
-
Coreysan 1,816 Reputation points
2021-08-22T03:30:08.863+00:00 From what you both said, I'm going to assume it's something else I missed.
You both sound confident that it's not this implementation, right?Codebehind:
spCommand.Parameters.Add("@wnotes", SqlDbType.VarChar, -1).Value = wnotes;Stored Proc:
declare @wnotes varchar(max);I'll look to see if I overlooked something!
-
Bruce Barker 801 Reputation points
2021-08-22T15:19:04.483+00:00 Another thought. How do you know it’s truncated? Maybe the tool is you use to view the data is truncating the data.