Can I use SQL Server to create a txt file on the c drive. Can sql server do nay kind of file handling. Is there a command that i can use in my background job to automatically create a txt file that will show data from a particular table.
Never done it before .. Any ideas...
Help is appreciated.
ThanksIn the job step, choose type as OS command(CmdExec), in the command box, type:
osql -E -Q"select top 10 * from sysobjects" -o"c:\output.txt"
The output file is a txt format having the 10 rows in sysobjects table.|||or bcp, dts or echo|||I am using BCP and it works just fine. I get a txt file with tab seperated fields. Can i specify the character positions or lengths of each field so that all my fields line up at the same positions.
Help is appreciated.
I created a stored procedure with the below
declare @.filename varchar(50),
@.bcpcommand varchar(2000)
set @.filename = 'c:\report\media.txt'
print @.filename
set @.bcpcommand = 'bcp "select * from table" queryout "'+ @.filename -U -P'
exec master..xp_cmdshell @.bcpCommandsql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment