Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Write into text file

Author  Topic 

CanadaDBA

583 Posts

Posted - 2005-01-31 : 14:37:00
I'm going to create a stored procedure that checks for a text file. If it exists, appends a line to it. If id doesn't exist, creates it and appends the line to it. What commands are the most useful one?

Canada DBA

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-31 : 14:59:52
xp_cmdshell?

see
http://www.mindsdoor.net/SQLTsql/WriteTextFile.html
http://www.mindsdoor.net/SQLTsql/CheckIfFileExists.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-01-31 : 23:46:46
You might try the undocumented stored procedure, xp_fileexist.

More info at:
[url]http://www.sql-server-performance.com/ac_extended_stored_procedures.asp[/url]



-- Example & result set
exec master.dbo.xp_fileexist 'c:\boot.ini'

File Exists File is a Directory Parent Directory Exists
----------- ------------------- -----------------------
1 0 1




quote:
Originally posted by farhadr

I'm going to create a stored procedure that checks for a text file. If it exists, appends a line to it. If id doesn't exist, creates it and appends the line to it. What commands are the most useful one?

Canada DBA



Codo Ergo Sum
Go to Top of Page

CanadaDBA

583 Posts

Posted - 2005-02-01 : 10:00:28
Thank you both for great replies. I appreciate your time.

Canada DBA
Go to Top of Page
   

- Advertisement -