Home All Groups Group Topic Archive Search About

SQL 2005: Why does DECLARE varchar(MAX) in Stored Procedure not work?

Author
15 Sep 2006 3:56 PM
Andreas Klemt
Hallo,

I have a Stored Procedure with

DECLARE myString varchar(MAX)

Now when I set a text which is bigger than 8000 Bytes, it gets cut.
Why? I thougt SQL 2005 has now varchar(max)?

Thanks for any help!

Regards
Andreas Klemt

Author
15 Sep 2006 4:00 PM
Aaron Bertrand [SQL Server MVP]
> Now when I set a text which is bigger than 8000 Bytes, it gets cut.

Where does it get cut?  Are you using PRINT, SELECT, passing the parameter
to another stored procedure, inserting into a table, ...???
Author
15 Sep 2006 4:04 PM
ML
How did you verify whether a truncation occurred? What is the compatibility
level?


ML

---
http://milambda.blogspot.com/
Author
15 Sep 2006 4:07 PM
SQL Menace
Works for me

can you run this example

create procedure TestVarcharMax
@TestValue varchar(max)
as
select len(@TestValue)
GO

declare @v varchar(max)
select @v =  (replicate (cast('a' as varchar(max)), 9000))

exec TesTVarcharMax  @v

I get back 9000

Denis the SQL Menace
http://sqlservercode.blogspot.com/


(1 row(s) affected)
Andreas Klemt wrote:
Show quote
> Hallo,
>
> I have a Stored Procedure with
>
> DECLARE myString varchar(MAX)
>
> Now when I set a text which is bigger than 8000 Bytes, it gets cut.
> Why? I thougt SQL 2005 has now varchar(max)?
>
> Thanks for any help!
>
> Regards
> Andreas Klemt

AddThis Social Bookmark Button