T-SQL 将数据附加到 NTEXT 列
谁能帮我弄清楚为什么我从 SQL 脚本中收到以下错误?非常感谢任何和所有的帮助。
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
错误信息是:
消息 7135,16 级,状态 3,第 9 行 删除长度-19不在 可用文本、ntext 或的范围 图像数据。该声明已 终止。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
什么版本的 SQL Server?我强烈建议您将列更改为
NVARCHAR(MAX)
-NTEXT
,因为从 SQL Server 2005 开始,这种数据类型已被弃用,并且它是共事真是太痛苦了。另一方面,
NVARCHAR(MAX)
可以轻松支持所有常用的字符串操作函数,并且使用起来会更加容易!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 !