Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql 2008 data type for 2million+ characters

Posted on 2014-04-25
11
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

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

Expert Comment

by:Lee Savidge
ID: 40022337
nvarchar(max)
0
 
LVL 8

Expert Comment

by:ProjectChampion
ID: 40022350
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 143

Expert Comment

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

Author Comment

by:BeyondBGCM
ID: 40023257
i am using this data type only , but when i use this , it truncates the data and shows , half results
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40023302
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
ID: 40023312
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
ID: 40023339
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
ID: 40029578
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 1500 total points
ID: 40029621
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

660 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