问题
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.
回答1:
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.
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
来源:https://stackoverflow.com/questions/8507047/how-to-manipulate-ntext-type-data-in-stored-procedure-of-sql-server-2008