what is the suitable data type to save string more than 8000 character in SQL database?
+2
A:
For SQL Server 2005+ varchar(max)
or nvarchar(max)
depending on whether you need to save as unicode or not.
If you don't have this requirement (or anticipate ever needing it) the varchar
option is more space efficient.
You don't give a specific version of SQL Server in your question. Pre 2005 it would have been the text
datatype.
NB: In answer to your comment use 'varchar(max)' exactly as written. Don't substitute a number in for "max"!
Martin Smith
2010-05-22 22:07:21
I tried varchar(max) and nvarchar(max) but failed because max = 4000 for nvar and 8000 for var
salamonti
2010-05-22 22:11:04
I do this but it failed
salamonti
2010-05-22 22:16:29
Can you post the full piece of code that fails? Or explain in what context you are using it and getting a problem?
Martin Smith
2010-05-22 22:25:37
@salamonti: varchar(max) can **definitely** handle a lot more than 8000 characters! THere must be something else that's wrong with your SQL code or process - please post more info!
marc_s
2010-05-23 08:02:44
@salamonti You seem to have completely disregarded the request for further details but one more guess might be that if you are using it in ADO.NET in a place that requires a number you need to use -1.
Martin Smith
2010-05-23 09:35:22
sorry but it is worked good sorry for late the problem not in the data type I solved the problem and now working perfect thanks for help
salamonti
2010-05-24 00:02:52