附加三个VARCHAR(MAX)变量 [英] Append Three VARCHAR(MAX) variables
本文介绍了附加三个VARCHAR(MAX)变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DECLARE @FileBody1 VARCHAR(max)
,@FileBody2 VARCHAR(max)
,@FileBody3 VARCHAR(max)
,@StartingIndex INT
,@FileLength INT
SET @StartingIndex = 1
SELECT @FileLength = DATALENGTH(DC.FileBody) FROM Configuration DC WHERE DC.ID = 1
SELECT @FileBody1 = SUBSTRING(DC.FileBody,@StartingIndex,8000)FROM Configuration DC WHERE DC.ID = 1
SET @StartingIndex = @StartingIndex + 8000
SELECT @FileBody2 = SUBSTRING(DC.FileBody,@StartingIndex,8000) FROM Configuration DC WHERE DC.ID = 1
SET @StartingIndex = @StartingIndex + 8000
SELECT @FileBody3 = SUBSTRING(DC.FileBody,@StartingIndex,8000) FROM Configuration DC WHERE DC.ID = 1
select @FileBody1+''+@FileBody2+''+@FileBody3
推荐答案
你不能在实践中这样做,或者至少你不应该'' t。
想一想:如果你有两个字符串可以是一个字符串的最大长度,那么如果连接它们,结果可以有多长?答案:字符串最大长度的两倍......
You can''t in practice do that, or at least you shouldn''t.
Think about it: If you have two strings which can be the maximum length for a string, how long a string can the result be if you concatenate them? Answer: twice the maximum length of a string...
这篇关于附加三个VARCHAR(MAX)变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文