开发者

T-SQL appending data to NTEXT column

Can anyone help me figure out why I am getting the error below from the SQL script? Any and开发者_运维问答 all help is greatly appreciated.

DECLARE @Comment AS VARCHAR(2000) 
DECLARE @Len AS INT
SET @Comment = 'This is a test and only a test!'
SET @Len = LEN(@Comment)
DECLARE @ptr varbinary(16)
SELECT @ptr = TEXTPTR(Comments)
FROM [dbo].[StudentInfringement] AS SI
WHERE [SI].[InfringementId] = 2
UPDATETEXT [dbo].[StudentInfringement].[Comments] @ptr @Len NULL @Comment

Error message is:

Msg 7135, Level 16, State 3, Line 9 Deletion length -19 is not in the range of available text, ntext, or image data. The statement has been terminated.


What version of SQL Server?? I would strongly recommend you change your column to NVARCHAR(MAX) - NTEXT as a data type is deprecated as of SQL Server 2005, and it's just a royal pain to work with.

NVARCHAR(MAX) on the other hand easily supports all the usual string manipulation functions, and would be just all the much easier to use !

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜