Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2006, 01:39 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Text or Varchar types too small?

I am currently finishing up a project in sql server 2000 which is designed to send mass HTML e-mails via a web interface. The user is required to enter the message body (with an html formatting tool for colors, fonts, etc) and pick an HTML template to put around it.

The template is stored in the database as two varchar(8000) fields, one called TemplateTop, and one called TemplateBottom. Sticking the user-entered text in between the two makes up the text of the e-mail. Other fields in this table are a bigint for an ID, and a "subject" field, varchar(256).

Sounds simple, but I ran into problems when trying to make a new template by manually inserting HTML text into the TemplateTop and TemplateBottom fields. I realize that there is going to be a limit to the amount of text that can be stored in a field, but 8000 characters is MORE than enough for my needs. When copying and pasting into one of these fields (via Enterprise Manager), it takes only about the first 900 characters and gives me the error:
The value you entered is not consistent with the data type or length of the column, or over grid buffer limit.

Call me crazy, but wouldn't you think a varchar field with a size of 8000 would accept 8000 characters before giving an error like this? I had read elsewhere that the maximum "returned row" size is something like 8060 characters... so I adjusted TemplateTop to 2000, TemplateBottom to 1000 (for a total of about 3500 chars per line for this table), and got the exact same error, regardless of how small or large the other fields in the table were.

Evidently, the text type is supposed to be able to be used for very very very large amounts of text that will never have to be searched (which is applicable in this situation). Changing from varchar(8000) to "text" data types does absolutely nothing to solve this problem. I am not quite sure why.

So far, the only workaround that I have come up with is to make several varchar fields and combine them with the front end. This solution feels rediculous and counter-intuitive. Not only does this not feel like a good solution, I am ready to be done coding this project and don't want to have to spend several more hours making changes to what is already finished.

The total character count of the entire template, both top and bottom, is 3700 chars. I would imagine that this would not have to be split up across 5 varchar fields.

Anyone have a clue as to what is going on here?

 
Old September 29th, 2006, 02:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Your problem may be more of a limitation of Enterprise Manager than of SQL Server...

EM has a limit to the amount of data it can accept/display, but off the top of my head I can't recall what that is (1024 maybe?)

The maximum row size for any table is 8060 bytes, and the sum of all actual data lengths of all columns in the row may not exceed this value. You do not appear to have reached this limit, given your description.

If you want to update the columns manually, try updating them via an SQL UPDATE statement using Query Analyzer instead.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old October 2nd, 2006, 12:20 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like you get the gold star for the day :)

You were right, it is just enterprise manager being picky with me. It really seems odd that this would be a problem in such a program.

Thanks so much for your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem converting datatype text to varchar kwilliams SQL Server 2000 4 August 15th, 2008 07:59 AM
Text/large varchar fields in SQL server pseudomorph Classic ASP Databases 0 August 16th, 2006 11:50 PM
How to upload small text file from within my vb6 f method Beginning VB 6 1 April 19th, 2006 01:17 PM
Search all types of files containing text. salman Classic ASP Databases 9 April 6th, 2005 02:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.