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.
我想知道如何在SQL Server 2008的存储过程中操作ntext数据类型。我们在表中有一个类型为ntext的列。我们必须从该列获取数据,解析数据,更改数据,然后将其存储回来。对于上述所有任务,我们必须使用一个或多个存储过程/函数。因此,存储过程之间的数据传递也涉及到。
1 个解决方案
#1
7
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)。后者是SQL Server 2005中的新版本,效率更高,并且可以使用字符串函数。
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:
如果不能更改模式,则将ntext转换为nvarchar(max)类型的局部变量。字符串函数与nvarchar(max)一起工作。例子:
declare @txt nvarchar(max)
select @txt = NTextField from YourTable where id = @ID
... process @txt ...
update YourTable set NTextField = @txt where id = @ID
#1
7
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)。后者是SQL Server 2005中的新版本,效率更高,并且可以使用字符串函数。
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:
如果不能更改模式,则将ntext转换为nvarchar(max)类型的局部变量。字符串函数与nvarchar(max)一起工作。例子:
declare @txt nvarchar(max)
select @txt = NTextField from YourTable where id = @ID
... process @txt ...
update YourTable set NTextField = @txt where id = @ID