×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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

 

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

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.

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

(OP)
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.

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

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?

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

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close