Solved

Sql 2008 data type for 2million+ characters

Posted on 2014-04-25
11
171 Views
Last Modified: 2014-05-22
hi

what data type should i use in a procedure , to pass the content of a story having more than 2 millions character.
0
Comment
Question by:BeyondBGCM
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

by:ProjectChampion
Comment Utility
Depending on the encoding type (unicode/non-unicode) you can use nvarchar(max) or varchar(max).
0
 
LVL 25

Expert Comment

by:Lee Savidge
Comment Utility
nvarchar(max)
0
 
LVL 8

Expert Comment

by:ProjectChampion
Comment Utility
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.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
I agree, varchar(max) or nvarchar(max), having a capacity near to 2GB
0
 

Author Comment

by:BeyondBGCM
Comment Utility
i am using this data type only , but when i use this , it truncates the data and shows , half results
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
Where exactly do you have this issue?

In ssms you have indeed a cutoff, but the data is there
0
 
LVL 8

Expert Comment

by:ProjectChampion
Comment Utility
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;
0
 
LVL 8

Expert Comment

by:ProjectChampion
Comment Utility
Hi Angel, : )
I didn't see you've already replied... I'm using my mobile and the connection is not so fast.  

Best Regards.
0
 

Author Comment

by:BeyondBGCM
Comment Utility
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.
0
 
LVL 8

Accepted Solution

by:
ProjectChampion earned 500 total points
Comment Utility
If you're using sp_send_dbmail, then there shouldn't be any problem with the proc per se, because it accepts an nvarchar(max) for its @body parameter.
However it also depends on the code that generates the @body and passes it to the proc.
You should be able to find where the real problem is by checking the data stored in the database first and then any code that gets the data out of the database and passes it to the proc.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now