Groups | Blog | Home
all groups > sql server (alternate) > february 2004 >

sql server (alternate) : write text files in transac sql


ragaza NO[at]SPAM ozu.es
2/6/2004 12:14:10 AM
Hi

I need create, write and read text files in a procedure transac sql
from sql server 2000
How i do this ??




Simon Hayes
2/6/2004 6:38:34 PM

[quoted text, click to view]

To read in a file of data to a table, you can use BULK INSERT, but
unfortunately there is no equivalent for writing out to a file. A common
solution is to use xp_cmdshell to call bcp.exe or osql.exe.

An alternative, if you have the appropriate permissions, is to use the
sp_OA% procedures to instantiate the FileSystemObject and read/write that
way. Or perhaps write an external script, then execute it using xp_cmdshell.

Simon

Erland Sommarskog
2/6/2004 11:45:08 PM
raulgz (ragaza@ozu.es) writes:
[quoted text, click to view]

In additions to Simon's response, I like to add that you should think
twice before you do this. If you are importing and exporting data,
that's alright. Use BULK INSERT or call bcp from xp_cmdshell. But if
you are up to something else, you should probably consider to do it
client-side.

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
raul garcia zamarra
2/9/2004 8:48:56 AM


Thank very much,

Really I need create txt files with dinamic
sql reading sql server catalog, the bettet solution
is create this files in client side.


Thanks again


RaulGZ.

*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button