Link to home
Start Free TrialLog in
Avatar of BeyondBGCM
BeyondBGCM

asked on

Sql 2008 data type for 2million+ characters

hi

what data type should i use in a procedure , to pass the content of a story having more than 2 millions character.
Avatar of ProjectChampion
ProjectChampion
Flag of United Kingdom of Great Britain and Northern Ireland image

Depending on the encoding type (unicode/non-unicode) you can use nvarchar(max) or varchar(max).
Avatar of Lee
nvarchar(max)
As mentioned earlier nvarchar is for unicode and varchar is for non-unicode. If you don't expect unicode (e.g. foreign alphabets etc.) then varchar makes better sense as it uses one byte for storing each character, i.e. half the requirement of nvarchar, which makes a huge difference not only in storage requirements, but also in I/O and therefore in performance, especially when dealing with such large character strings.
I agree, varchar(max) or nvarchar(max), having a capacity near to 2GB
Avatar of BeyondBGCM
BeyondBGCM

ASKER

i am using this data type only , but when i use this , it truncates the data and shows , half results
Where exactly do you have this issue?

In ssms you have indeed a cutoff, but the data is there
How do you know if it's truncated the results? Please note that Management Studio truncates large data for display purposes, but the actual data in the table is probably OK. You should be able to test it using something like:
SELECT LEN(my_col), my_col FROM my_table;
Hi Angel, : )
I didn't see you've already replied... I'm using my mobile and the connection is not so fast.  

Best Regards.
hi

actually i am using one procedure , where the parameter is of type varchar(max), and i am passing a large string to it from C# application ,  and now i want this passed string to be displayed in a mail ,which is triggered from database.

is this is a problem of database mail , which doesn't accept a long string.
ASKER CERTIFIED SOLUTION
Avatar of ProjectChampion
ProjectChampion
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial