declare @s nvarchar(4000)
Declare @path nvarchar(1000)
Set @path = 'C:/inetsdk/'
if right(@path,1)<>'/' set @path=@path+'/'
--用游标构建每条记录的bcp导出语句,BCP的语法参考sql联机帮助
declare Cur_Form cursor local
for
select 'BCP "select FormData from '
+ quotename(db_name())
+'..sysform Where id='
+ convert(nvarchar(10),id)
+'" queryout "'+@path
+ FormName + '.ofm" /w'
from sysform where id=28
--charindex('CRM_',formname)>0
open Cur_Form
fetch Cur_Form into @s
while @@fetch_status=0
begin
--调用xp_cmdshell存储过程执行bcp进行导出处理
exec master..xp_cmdshell @s,no_output
fetch Cur_Form into @s
end
close Cur_Form
deallocate Cur_Form