MsSql 数据表中把字段类型为text的字段内容导出为文本文件

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
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值