Yep!! VARCHAR supports text up to 2GB but my character string length is more than 8000. VARCHAR truncates anything more than 8000 characters
Main Topics
Browse All TopicsHi Experts,
I am using a VARCHAR(MAX) parameter in one of the stored procedures. Recently i discovered it might get bigger than 8000 characters. So i changed that parameter to TEXT. But problem is i cannot use RTRIM, LTRIM functions on TEXT datatype. Is there any work around for this problem?
Thanks
Raju
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
varchar(max) should be used everywhere that text used to be used. See the excerpt below from BOL.
ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. For more information, see Using Large-Value Data Types.
http://msdn.microsoft.com/
That is exactly the way i declared my parameter.
you are saying that even if the string length is more than 8000, it will show everything if the size is below 2GB? It is not happening.
Here is little bit more detail of my problem:
I have this report (SSRS) which has a parameter called Resources. i pass in this parameter to a stored procedure. Parameter is just bunch of comma separated Id's. When i print this parameter using TEXT(storage space is 2GB for this too) datatype, length of the parameter is 8792 and if i print it using VARCHAR(MAX), length is 8000. So it is clearly truncating the parameter to 8000 characters unless i am missing something.
Thanks
Raju
No... what are you doing trying to put (text) after varchar(max)?
varchar(MAX) does not truncate. If you declare a parameter as varchar(8000)
Try this:
declare @a varchar(max)
set @a=replicatE('a',8000)
set @a=@a+@a
select len(@a)
replicate won't product a string longer than 8000, but that's not a limitation of the data type, it's a limitation of the replicate function.
Business Accounts
Answer for Membership
by: BrandonGalderisiPosted on 2008-10-03 at 09:19:51ID: 22635435
varchar(max) supports text up to 2GB. No need to use text.