Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Long string of text being cut off

Author  Topic 

benking9987
Posting Yak Master

124 Posts

Posted - 2012-03-09 : 15:03:45
I have a SELECT statement that is generating a long series of text (its actually pre-formatted HTML code). Within the HTML code it is generating I am inserting fields for dynamic data content. The resulting string should be about 11,000 characters (its the HTML content for a custom eBay listing)

When I generate the SELECT statement, the resulting text is being limited to 8,000 characters.

Does anyone know how to get more out of this?

My SELECT statement was just my test environment. I'm actually planning to update a field on a table with the same values of the select statement, so I'm assuming that would have problems with 8,000 characters as well.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-03-09 : 15:52:47
1. Use the proper datatype (N)VARCHAR(MAX).
2. Use explicit rather thean implicit CASTing to prevent SQL from using VARCHAR(8000).
Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2012-03-09 : 16:16:23
I think I did that...

Here is my total code:



SELECT Parent_SKU, CAST('HTML CODE' AS VARCHAR(MAX)) AS EB_Description

FROM Parent_Table
WHERE (copy_OSDescription IS NOT NULL) AND (Image1_URL IS NOT NULL) AND (Image2_URL IS NOT NULL) AND (Image3_URL IS NOT NULL) AND (Image4_URL IS NOT NULL)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-10 : 15:06:17
quote:
Originally posted by benking9987

I think I did that...

Here is my total code:



SELECT Parent_SKU, CAST('HTML CODE' AS VARCHAR(MAX)) AS EB_Description

FROM Parent_Table
WHERE (copy_OSDescription IS NOT NULL) AND (Image1_URL IS NOT NULL) AND (Image2_URL IS NOT NULL) AND (Image3_URL IS NOT NULL) AND (Image4_URL IS NOT NULL)



why you've '' around column name? it will treat it as a string instead

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2012-03-12 : 15:39:50
Visakh: I know that when I place the code within '' that it will be treated as text. This is what i want. The text that goes within the '' is very long, so i didn't want to post it here. Instead, I put 'HTML CODE'.

The problem is that the HTML code is too long and SQL is treating the selection as VARCHAR(8000). I need to to allow more characters within the SELECT statement.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-12 : 16:45:41
so where do get this long string from?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2012-03-12 : 17:02:49
It is a static string of text that when placed in an HMTL setting generates a web page. Within the SQL query, i have dynamic data flowing from multiple fields within my table structure. The result is a dynamic HTML code that I can use for my client's ebay listings.

I decided to just break up the results into two smaller chunks and I am achieving the same thing at this point.

Thanks all for your input on this.
Go to Top of Page
   

- Advertisement -