varchar cutting at 257th

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mawron (mawronthefounder_at_SPAMBLOCKyahoo.it)
Date: 08/09/04


Date: Mon, 09 Aug 2004 11:25:27 GMT

Hi to all.
Please take a look at this simple code and the inline comments:

-- start here --
declare @t varchar(2000)

set @t='12345678901234567890' -- 20 chars
set @t=@t+@t -- @t now contains 40chars
set @t=@t+@t -- 80
set @t=@t+@t -- 160
set @t=@t+@t -- 320
set @t=@t+@t -- 640 chars

-- this line print all the 640 characters
print @t

-- the table has a column declared as varchar(2000)
insert into table
(columnName)
values
(@t)

-- the query should return all the 640 chars, but...
-- only the first 257 chars are memorized! :(
select *
from table
-- stop here --

The code comes from a stored procedure I wrote to test my real db table.
Why only the first 257 chars are inserted? I don't understand... :(

-- 
    .   .     *      +
.    .   Mawron   .      *
    *     .   .       .  +


Relevant Pages

  • Re: Search Char in SQL query
    ... with chars in them. ... Tony Rogerson wrote: ... declare @numbers table ( ... SQL Server MVP ...
    (comp.databases.ms-sqlserver)
  • Re: Search Char in SQL query
    ... with chars in them. ... Tony Rogerson wrote: ... declare @numbers table ( ... SQL Server MVP ...
    (comp.databases.ms-sqlserver)
  • Re: Return Value of Function ?!?!
    ... if you're trying to retrieve the text or "string" representation of chars then you need to declare the function as such, ...
    (comp.lang.basic.powerbasic)
  • Re: Implementation of functions in math.h on clc-wiki
    ... declare a cdecl function on gcc, and only one way to do so on msvc. ... In arbitrariness ... from a C++ inline and a C macro. ...
    (comp.lang.c)
  • Re: Need help - Cant run a simple C++ application
    ... > static function does not need code to be generated). ... The optimizer can move the function body at the location where it is ... If you declare a function as "inline" its always inlined. ...
    (comp.os.linux.questions)