国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

逐記錄導出text/ntext字段值為文本文件

2024-07-21 02:05:36
字體:
來源:轉載
供稿:網友
  • 網站運營seo文章大全
  • 提供全面的站長運營經驗及seo技術!

  • /*--原帖地址:http://community.csdn.net/expert/topic/3851/3851741.xml?temp=.4726831--*/

    --測試數據create table tb(id varchar(50) primary key,detail text)insert tb select 'aaa','11111'union all select 'bbb','43424'union all select 'ccc','324234'

    /*--處理要求

     把上述表中的detail字段導出為文本文件,要求每條記錄一個文件,文件名為id+.txt 即上述表中的數據要求導出為 aaa.txt,bbb.txt,ccc.txt--*/go

    --處理的存儲過程create proc [email protected] nvarchar(1000)  --導出的文本文件保存的目錄asdeclare @s nvarchar(4000)if isnull(@path,'')='' set @path='c:/'else if right(@path,1)<>'/' set @[email protected]+'/'

    --用游標構建每條記錄的bcp導出語句,bcp的語法參考sql聯機幫助declare tb cursor localforselect 'bcp "select detail from ' +quotename(db_name()) +'..tb where id=' +quotename(id,n'''') +'" queryout "'[email protected] +id+'.txt" /t /w'from tbopen tb fetch tb into @swhile @@fetch_status=0begin --調用xp_cmdshell存儲過程執行bcp進行導出處理 exec master..xp_cmdshell @s,no_output fetch tb into @sendclose tbdeallocate tbgo

    --調用exec p_export 'c:/'go

    --刪除測試drop table tbdrop proc p_export
    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 交口县| 蛟河市| 台江县| 天等县| 墨竹工卡县| 即墨市| 咸宁市| 稷山县| 祥云县| 和龙市| 宁波市| 铅山县| 灵川县| 金平| 曲阳县| 新巴尔虎左旗| 林周县| 广饶县| 青铜峡市| 景谷| 永清县| 桃江县| 徐汇区| 始兴县| 灵丘县| 得荣县| 七台河市| 建宁县| 吴堡县| 德庆县| 绵竹市| 普安县| 桦川县| 建始县| 临沭县| 鹤岗市| 资溪县| 略阳县| 肥城市| 赤峰市| 长岭县|