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
 General SQL Server Forums
 New to SQL Server Programming
 varchar(max)

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-07-11 : 06:37:22
since varchar(max) is the replacement of text datatype in sql2k .iam trying to 10000 character,but it allowing
only 8000 character,can any one correct if iam wrong

declare @n varchar(max)
set @n = replicate('K',10000)
select datalength(@n)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-11 : 06:46:36
The replicate function still only allows 8000 characters.

set @n = replicate('K',10000) + replicate('K',10000)
select datalength(@n)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-07-11 : 06:52:39
hi peso,
Even ur query is showing only 8000 character
quote:
Originally posted by Peso

The replicate function still only allows 8000 characters.

set @n = replicate('K',10000) + replicate('K',10000)
select datalength(@n)



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-11 : 06:56:01
[code]declare @n varchar(max)
set @n = replicate('K',10000)
set @n =@n + replicate('K',10000)

select datalength(@n)[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-11 : 07:04:43
To get what you wanted, use

declare @n varchar(max)
set @n = replicate(cast('K' as varchar(max)) ,10000)
set @n =@n + replicate(cast('K' as varchar(max)) ,10000)

select datalength(@n)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-07-11 : 07:16:49
txs peso i got it..

quote:
Originally posted by Peso

declare @n varchar(max) 
set @n = replicate('K',10000)
set @n =@n + replicate('K',10000)

select datalength(@n)



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page
   

- Advertisement -