473,773 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5613
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_sendmai l, 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
2938
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 flexible and solid wrapper and am deep into coding. The only problem is a noticed VARCHAR fields being drawn from SQL Server 2000 are being truncated to 255 characters. I searched around php.net and found the following : Note to Win32 Users: Due...
6
22423
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 data type to some numeric type? I would have to update the column's data to accomodate this, but I would do it if this offers a performance gain. -- Bill
5
29499
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 reason why he would have done this over using varchar? It's a minor annoyance to always have to RTRIM data and it makes directly making changes to the database more annoying (with all the pointless trailing spaces)? I usually use char for fixed...
2
2353
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 this topic on this when I Google it. Currently the field is Char(4), and there is a need to increase it to hold 5 characters. TIA
18
5986
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 the table is define so that one particular column has datatype VARCHAR(2000) . The table was recently modified so that the data type for
7
4785
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 MAXVALUE +2147483647 NO CYCLE
5
18343
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
20475
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 max. 10 characters string (but the string may be filled i.e. with only 5 charachters). Should I define these primary keys as char or varchar? I'm interested in your opinion in particular about performace issue, because there will be tables with...
5
2752
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 the string contains. So, varchar sounds more efficient, but are there any disadvanages of using varchar over char (eg speed and size)? If I wish to store ISBNs (which can be 10 or 13 characters, using characters 0-9 and X) would char(13) be a...
6
4275
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 long. These names get printed on envelopes. The problem is the envelope can only hold 35 characters per line. I have to divide into 4 lines at most. So I need to separate these long varchars into segments, no longer
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.