Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to export query data from MS SQL Server to text file

Status
Not open for further replies.

2Plan

MIS
Mar 29, 2005
55
0
0
US
Need to export the MS SQL Server query data to the (fixed)text format below. (e.g. columns/rows must appear in fixed format)

Rout Block_ _Date_ D Bus_ D Trip Time_ On_ Off

392 392001 102008 1 7036 6 0451 25.0 2 0
392 392001 102008 1 7036 0 0516 28.0 7 8
392 392001 102008 1 7036 1 0600 42.0 19 19
392 392001 102008 1 7036 0 0700 48.0 15 18
392 392001 102008 1 7036 1 0800 46.0 17 15
392 392001 102008 1 7036 0 0900 50.0 6 8
392 392001 102008 1 7036 1 1000 48.0 9 10
392 392001 102008 1 7036 0 1100 50.0 20 27
392 392001 102008 1 7036 1 1200 48.0 16 10
392 392001 102008 1 7036 0 1300 50.0 16 18
392 392001 102008 1 7036 1 1400 50.0 31 27
392 392001 102008 1 7036 0 1500 51.0 22 22
392 392001 102008 1 7036 1 1600 48.0 23 23

 
New DTS package - create the connection (server / database). Create a new object for data destination using the text file option. On the advanced tab, check "fixed" so it is fixed width, then set up a data pump task either using a SQL statement or if it is the entire table, do it that way.

Rgds,

M.
 
I will only have access (possibly only read-only access and ability to export) to the SQL Server 2005 Management Studio or the SQLCMD utility to export the data to a "fixed width" text file.

Is there a script or Transact-SQL code that I can run in the SQL Server 2005 Management Studio or the SQLCMD utility to export the data to a "fixed width" text file?

Thanks in advance for any assistance.
 
1. Please don't double post across groups
2. If it's 2005 then it would be SSIS and not DTS

In either case, see previous response - there is an export option of fixed width - or are you asking for something completely different?
 
Thanks mutley1. Apologize for the double post.

I will post any other questions in the SQL Server Programming forum instead of the Data Transformation forum.

Thanks again, for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top