开发者

How to assign large concatenated string in sql server

How to assign a large text more than 8000 characters in SQL serve开发者_运维百科r

Thanks, Vara Prasad.M


Use one of the max types but beware that any intermediate expressions will be varchar(8000) (or nvarchar(4000)) unless they involve the (n)varchar(max) type

DECLARE @maxtype varchar(max)

--on the right, never above 8000
SET @maxtype = REPLICATE('a', 6000) + REPLICATE('b', 6000)
SELECT LEN(@maxtype) --8000

--here, there is a max on the right
SET @maxtype = REPLICATE(CAST('a' AS varchar(max)), 6000) + REPLICATE('b', 6000)
SELECT LEN(@maxtype) --12000


Use a VARCHAR(MAX) or NVARCHAR(MAX) data type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜