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

首頁 > 開發(fā) > 綜合 > 正文

用SQL在文本文件中追加數(shù)據(jù)

2024-07-21 02:07:56
字體:
來源:轉載
供稿:網(wǎng)友

if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[p_movefile]') and objectproperty(id, n'isprocedure') = 1)
drop procedure [dbo].[p_movefile]
go

/*--在文本文件中追加數(shù)據(jù)

 在文本文件中追加數(shù)據(jù)
 如果文件不存在,將創(chuàng)建文件

--鄒建 2004.08(引用請保留此信息)--*/

/*--調(diào)用示例

 exec p_movefile 'c:/aa.txt','測試寫入'
--*/
create proc p_movefile
@filename varchar(1000),--要操作的文本文件名
@text varchar(8000) --要寫入的內(nèi)容
as
declare @err int,@src varchar(255),@desc varchar(255)
declare @obj int

exec @err=sp_oacreate 'scripting.filesystemobject',@obj out
if @err<>0 goto lberr

exec @err=sp_oamethod @obj,'opentextfile',@obj out,@filename,8,1
if @err<>0 goto lberr

exec @err=sp_oamethod @obj,'writeline',null,@text
if @err<>0 goto lberr

exec @err=sp_oadestroy @obj
return

lberr:
 exec sp_oageterrorinfo 0,@src out,@desc out
 select cast(@err as varbinary(4)) as 錯誤號
  ,@src as 錯誤源,@desc as 錯誤描述
go

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 雷州市| 县级市| 奇台县| 秦皇岛市| 福贡县| 屯昌县| 民县| 望都县| 庐江县| 满城县| 镇沅| 司法| 潮安县| 长丰县| 陆良县| 安国市| 宁陵县| 夏津县| 鸡泽县| 通化县| 博野县| 洞头县| 文登市| 鄂伦春自治旗| 木兰县| 宜城市| 彰武县| 西乌| 通辽市| 灵丘县| 屯门区| 家居| 璧山县| 蓝山县| 云龙县| 洮南市| 眉山市| 南召县| 克山县| 曲麻莱县| 清丰县|