473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

varchar only up to 256 characters?

When I run the code below, SELECT LEN(@mytext) prints 300 as expected.
Yet SELECT @mytext only prints the first 256 characters.

Isn't varchar supposed to have up to 8000? Is there something from the
discrete math class I am forgetting here? Sorry, that was over 10 years
ago.

DECLARE @mytext varchar(500)

SELECT @mytext = '1111111111'
select @mytext = @mytext + '2222222222'
select @mytext = @mytext + '3333333333'
select @mytext = @mytext + '4444444444'
select @mytext = @mytext + '5555555555'
select @mytext = @mytext + '6666666666'
select @mytext = @mytext + '7777777777'
select @mytext = @mytext + '8888888888'
select @mytext = @mytext + '9999999999'
select @mytext = @mytext + '0000000000'

select @mytext = @mytext + '1111111111'
select @mytext = @mytext + '2222222222'
select @mytext = @mytext + '3333333333'
select @mytext = @mytext + '4444444444'
select @mytext = @mytext + '5555555555'
select @mytext = @mytext + '6666666666'
select @mytext = @mytext + '7777777777'
select @mytext = @mytext + '8888888888'
select @mytext = @mytext + '9999999999'
select @mytext = @mytext + '0000000000'

select @mytext = @mytext + '1111111111'
select @mytext = @mytext + '2222222222'
select @mytext = @mytext + '3333333333'
select @mytext = @mytext + '444444444'
select @mytext = @mytext + '5555555555'
select @mytext = @mytext + '6666666666'
select @mytext = @mytext + '7777777777'
select @mytext = @mytext + '8888888888'
select @mytext = @mytext + '9999999999'
select @mytext = @mytext + '0000000000'

SELECT LEN(@mytext)
SELECT @mytext
*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #1
4 5588
I'm guessing you're using Query Analyzer? It only displays 256
characters per column by default - you can change this in Tools -
Options - Results (the maximum value is 8192)

And check out the REPLICATE() function in Books Online:

set @mytext = replicate('x', 300)

Simon

Jul 23 '05 #2


Thank you. With my varchar, I am doing more than just displaying it
using QueryAnalyzer. The string is being sent via email, but in the
email, it is cut off at 256.

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #3
In that case, you'll have to give more details of how you're sending
the email (xp_sendmail, xp_smtp_sendmail, an external script or tool
etc.), and how you pass @mytext to the email program. Is it a stored
procedure parameter, is it INSERTed into a table and then picked up by
the email program etc.?

It seems likely that somewhere a variable, parameter or table column
has been declared as varchar(256) instead of something larger, but
without more information it's hard to say.

Simon

Jul 23 '05 #4
How are you generating the email? I'm guessing that somewhere you are
passing the string as a parameter that's declared as VARCHAR/CHAR
(256). The @message param of xp_sendmail supports up to 8000
characters.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: James | last post by:
I am currently working on a PHP based website that needs to be able to draw from Oracle, MS SQL Server, MySQL and given time and demand other RDBMS. I took a lot of time and care creating a...
6
by: Bill | last post by:
In an effort to improve the speed of queries against my main table, I'll be indexing a column whose data type is varchar(50). Would I be better off (better performance) if I changed the column's...
5
by: dmhendricks | last post by:
Greetings, I have a question. I work on some SQL2k/ASP.NET apps at work. My predacessor, who created the databases/tables seemed to have liked to use 'char' for all text fields. Is there a...
2
by: Miss Livvy | last post by:
Would it be OK to use varchar(5) instead of char(5) as the first field of a composite clustered index? My gut tells me that varchar would be a bad idea, but I am not finding much information on...
18
by: gimme_this_gimme_that | last post by:
I'm driving Weblogic 8.1.3 on WinTel. DB2 8.1.4 on Sun64. I'm using Weblogic DB2's Type 2 driver, which has been very reliable - so far. I have a PreparedStatement that updates perfectly when...
7
by: James o'konnor | last post by:
hello. i have the next for create one table into db2 CREATE TABLE "MYSQUEMA"."TABLADEMO" ( "ID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +0 INCREMENT BY +1 MINVALUE +0...
5
by: haidani | last post by:
Hi, I am new to MS SQL. When I create a column in a table, when shall I use nvarchar or varchar? Please help. Thanks, Mike
7
by: D. | last post by:
Hi, I'm planning the structure of a SqlServer 2005 database for a new application. The requirement is that primary keys must be "natural"; i.e. in the table Customers the primary key will be a...
5
by: Jay | last post by:
My understanding is that char stores a fixed number of characters even if the string stored in the char has fewer characters, whereas varchar stores the string with the number of characters that...
6
by: jephperro | last post by:
Hi there, I'm having a really tough time with a SQL statement and I am wondering if someone is able to help out or point me in the right direction. I have a table of names which can be very...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.