我有一个要提取的列,但遇到了问题!该列存储为 ntext 类型并包含一个 RTF 文档,因此看起来像这样:
{\rtf1\ansi\ansicpg1252\uc1\deff0{\fonttbl {\f0\fnil\fcharset0\fprq2 Arial;} {\f1\fswiss\fcharset0\fprq2 Arial;} {\f2\froman\fcharset2\fprq2 Symbol;}} {\colortbl;\red0\green0\blue0;\red255\green255\blue255;} {\stylesheet{\s0\itap0\nowidctlpar\f0\fs24 [Normal];}{\*\cs10\additive Default Paragraph Font;}} {\*\generator TX_RTF32 15.0.530.502;} \deftab1134\paperw11909\paperh16834\margl1138\margt1138\margr1138\margb1138\widowctrl\formshade\sectd \headery720\footery720\pgwsxn11909\pghsxn16834\marglsxn1134\margtsxn1134\margrsxn1134\margbsxn1134\pard\itap0\nowidctlpar\plain\f1\fs20 Stephan Bos 28/11/2011 11:19:55\par\par Sold in guy. He likes him, feedback this afternoon.\par Will send him the CV and also our terms.\par Made him aware of our fees.\par }
但我希望将其提取回(rtf 或 txt,我并不介意)我尝试使用 BCP,它已成功提取文档,但它们最终与列完全相同,但在每个字符而不是我所期望的(上面的例子最终会读到类似的内容:
Stephan Bos 28/11/2011 11:19:55
Sold in guy. He likes him, feedback this afternoon.
Will send him the CV and also our terms.
Made him aware of our fees.
我正在使用(正在提取)的 BCP 提取如下:
set nocount on;
Declare @sql varchar(1000);
declare @noteid int;
declare xx1 cursor for select nic.NotebookItemId from NotebookItemContent nic
inner join NotebookLinks nl on nl.NotebookItemId = nic.NotebookItemId
inner join NotebookItems ni on ni.NotebookItemId = nic.NotebookItemId
where nl.clientid = 1235074
AND ni.NotebookTypeId = 56;
open xx1;
fetch xx1 into @noteid;
while (@@fetch_status = 0)
begin
set @sql = 'BCP "SELECT memo FROM Monarch_Pronet_ITOIL.dbo.notebookitemcontent where notebookitemid=' + cast(@noteid as varchar) +
'" QUERYOUT \\bhamws475\docs\' + cast(@noteid as varchar) + '.rtf -T -f \\bhamws475\docs\bcp.fmt -S ' + @@SERVERNAME
EXEC master.dbo.xp_CmdShell @sql
fetch xx1 into @noteid;
end;
close xx1;
deallocate xx1;
谁能指出我正确的方向?