查询分析器中打印Ntext类型数据--DATALENGTH(),SUBSTRING(),CHAR(13),WHILE
DECLARE @data NVARCHAR(4000)
DECLARE @length INT
DECLARE @loopnumber INT
DECLARE @count INT
SELECT @data = CONVERT(NVARCHAR(4000), flowerdata),@length=DATALENGTH(flowerdata)
FROM itp_flowerData
WHERE serial = 40
PRINT 'The length of NTEXT field data: '
+ CHAR(13) + CHAR(13) + CONVERT(NVARCHAR(10), @length) + CHAR(13) + CHAR(13)
PRINT 'The NTEXT field data(XML): '
+ CHAR(13) + CHAR(13)
SET @loopnumber = 0
SET @count = @length / 3500 + 1
WHILE @loopnumber <= @count
BEGIN
PRINT SUBSTRING(@data, @loopnumber * 3500, 3500 )
SET @loopnumber = @loopnumber + 1
END
DECLARE @length INT
DECLARE @loopnumber INT
DECLARE @count INT
SELECT @data = CONVERT(NVARCHAR(4000), flowerdata),@length=DATALENGTH(flowerdata)
FROM itp_flowerData
WHERE serial = 40
PRINT 'The length of NTEXT field data: '
+ CHAR(13) + CHAR(13) + CONVERT(NVARCHAR(10), @length) + CHAR(13) + CHAR(13)
PRINT 'The NTEXT field data(XML): '
+ CHAR(13) + CHAR(13)
SET @loopnumber = 0
SET @count = @length / 3500 + 1
WHILE @loopnumber <= @count
BEGIN
PRINT SUBSTRING(@data, @loopnumber * 3500, 3500 )
SET @loopnumber = @loopnumber + 1
END