SQL Server 2008的存储过程中如何操作ntext类型的数据 [英] How to manipulate ntext type data in stored procedure of SQL Server 2008

查看:36
本文介绍了SQL Server 2008的存储过程中如何操作ntext类型的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在 SQL Server 2008 的存储过程中操作 ntext 数据类型.我们在表中有一个 ntext 类型的列.我们必须从该列中获取数据,解析数据,更改然后将其存储回来.对于上述所有任务,我们必须使用一个或多个存储过程/函数.所以也涉及到存储过程之间的数据传递.

I was wondering how to manipulate ntext datatype in stored procedure of SQL Server 2008. We have a column of type ntext in a table. We have to fetch data from that column, parse the data, change and then store it back. For all of the above task we have to use one or more than on stored procedure/function. So data passing between stored procedures are also involved.

推荐答案

如果您可以更改架构,请考虑将数据类型从 ntext 更改为 nvarchar(max).后者是 SQL Server 2005 中的新增功能,效率更高,并且可以与字符串函数一起使用.

If you're in the position to change the schema, consider changing the data type from ntext to nvarchar(max). The later is new in SQL Server 2005, it's more efficient, and it works with string functions.

如果您无法更改架构,请将 ntext 转换为 nvarchar(max) 类型的局部变量.字符串函数与 nvarchar(max) 一起工作.示例:

If you can't change the schema, convert the ntext to a local variable of type nvarchar(max). String functions do work with nvarchar(max). Example:

declare @txt nvarchar(max)
select @txt = NTextField from YourTable where id = @ID

... process @txt ...

update YourTable set NTextField = @txt where id = @ID

这篇关于SQL Server 2008的存储过程中如何操作ntext类型的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆