1

I need to pass a very long string parameter from C# to MSSQL server stored procedure via entity framework. For this, Im thinking to use VARCHAR(MAX) as the input parameter type of the stored procedure. and I found that VARCHAR(MAX) supports up to 2^31-1 characters to be stored from the below links.

But, what worries me is when I pass this long string to stored procedure will there be any data loses during the communication from C# to sql server stored procedure, so that VARCHAR(MAX) input parameter would not receive all the characters that sent from C#?

Any guidance or help will be much appreciated. Thanks.

https://learn.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server

Maximum length of string which can be returned from stored proc in SQL Server 2008 to .net apps

BUDDHIKA
  • 306
  • 2
  • 8
  • 23
  • Why do you think about a data loss if your string is less than the MAX limit? Do you have proof of any problem with this? – Steve Dec 07 '17 at 07:40
  • No, I do not have proof. But, I had difficulties in finding if there are data loses associated with this and wanted get some guidance before implementing this with a long string rather dividing long string to smaller chunks, but in that way it would increase the number of database calls. – BUDDHIKA Dec 07 '17 at 07:46
  • sql server will throw an exception if the string you passed is exceeded the length of varchar(max) – rjps12 Dec 07 '17 at 08:07
  • Hypothetical question, you must try creating some sample code first, find out the limits yourself and if getting any issue then ask. – Sunil Dec 07 '17 at 09:44
  • Thanks for the help. Will run some tests. – BUDDHIKA Dec 11 '17 at 10:39

0 Answers0