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 2000 Forums
 Transact-SQL (2000)
 Declaring Varchar Variable Length

Author  Topic 

rmuscarello
Starting Member

7 Posts

Posted - 2002-06-03 : 10:05:41
I'm trying to declare a variable as a varchar with a length > 255 and it's not expanding beyond that. I would like it to have a length of 8000. My question is why won't the field go to a length of 8000?

This is how I'm try to declare the variable:

DECLARE @email varchar(8000)
SELECT @email='' select @email=@email+database.dbo.table.email+';'
FROM database.dbo.table

Thanks in advance!
Roger

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-03 : 10:12:52
What version of SQL Server are you using? SQL 6.5 and earlier only support a maximum of 255 characters for varchar.

Go to Top of Page

rmuscarello
Starting Member

7 Posts

Posted - 2002-06-03 : 10:22:23
I'm using SQL 7.0 SP4
Go to Top of Page

Nazim
A custom title

1408 Posts

Posted - 2002-06-03 : 10:32:34
Are you getting any error Message????

What are you trying to do and how did you came to the conclusion it isnt expanding??

can you post your entire script.

--------------------------------------------------------------
Go to Top of Page

izaltsman
A custom title

1139 Posts

Posted - 2002-06-03 : 10:42:00
If you went to display the value of your @email variable after running that query, and the Query Analyzer has shown you only the first 255 characters in the results window, then the size of the variable is not an issue -- you simply need to change one of the display options in QA to show more characters (255 is the default).
In QA go to Tools->Options->Results and enter 8000 in the "Max chars/column" box.

Go to Top of Page

rmuscarello
Starting Member

7 Posts

Posted - 2002-06-03 : 10:50:31
When I run the job it fails. When I look at the job history it shows part of someone’s email address. That's why it fails because it doesn't recognize the last email address as being valid. However when I changed the data in the database so the email addresses plus ";" and a space in between the email address adds up to 255 characters it works.
Go to Top of Page
   

- Advertisement -