[dba-SQLServer] Output to Text File

Billy Pang tuxedo_man at hotmail.com
Tue Jul 13 12:38:41 CDT 2004


Also, not sure if this is useful to you but QA can output results to text 
file on local machine without column headers... from QA, press CTNL+SHFT+F 
all at once when you execute a query and it will prompt for file name.

Billy


>From: "Shamil Salakhetdinov" <shamil at users.mns.ru>
>Reply-To: dba-sqlserver at databaseadvisors.com
>To: dba-sqlserver at databaseadvisors.com
>Subject: Re: [dba-SQLServer] Output to Text File
>Date: Tue, 13 Jul 2004 12:06:56 +0400
>
>Christopher,
>
>You can use bcp - here is a sample(watch line wraps) of one step T-SQL
>job:
>
>-- dropping temp table
>if exists (select * from tempdb.dbo.sysobjects where name = '##T1')
>    drop table [dbo].[##T1]
>go
>-- creating temp table
>CREATE TABLE ##T1 ( column_1 int, column_2 nvarchar(30))
>INSERT ##T1 VALUES (1, 'Row #1')
>INSERT ##T1 VALUES (2, 'Row #2')
>INSERT ##T1 VALUES (3, 'Row #3')
>go
>-- bcp-ing temp table data
>master..xp_cmdshell 'bcp ##T1 out
>d:\temp\export\temp_T1.txt -c -C850 -SYOUR_SERVER_NAME -T'
>go
>
>HTH,
>Shamil
>
>----- Original Message -----
>From: "Mackin, Christopher" <CMackin at Quiznos.com>
>To: <dba-sqlserver at databaseadvisors.com>
>Sent: Tuesday, July 13, 2004 3:36 AM
>Subject: [dba-SQLServer] Output to Text File
>
>
> > Hi,
> >
> > I have a daily fixed width text file that I need to produce and I am
>currently generating it via VBA code, but am trying to post it to a SQL
>Job.  I have it set up to output to the proper file, the problem is that
>at the top of the file there is header info that I need to eliminate.
>It looks like the following:
> >
> > Job 'VPP' : Step 1, 'Create File' : Began Executing 2114-17-12
>17:31:31
> >
> > OutputLine
> > ----------------------------------------------------------------------
>----------
> >   813             212111132122111119987 111446349317132114
> >   813             212111132122111119988 111619832817132114
> >
> > Starting with the 813 is the data that I need in there, everything
>above needs to go, does anyone know how to do this?
> >
> > Also, what other methods are people using to generate Text files from
>T-SQL?
> >
> > Thanks,
> > Chris Mackin
> > _______________________________________________
> > dba-SQLServer mailing list
> > dba-SQLServer at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> > http://www.databaseadvisors.com
> >
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>

_________________________________________________________________
STOP MORE SPAM with the MSN Premium and get 2 months FREE*    
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines




More information about the dba-SQLServer mailing list