SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql table to fixed width text file output
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Guruprasath.cub
Starting Member

India
8 Posts

Posted - 02/13/2012 :  06:16:59  Show Profile  Reply with Quote
Dear members,

I have sql table which contains data for various periods. Through asp, I need to generate for one particular period. After this the same output need to be taken out as fixed width txt file. Anybody, please help me

Guru

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 02/13/2012 :  07:50:41  Show Profile  Reply with Quote
Follow the HOW TO ASK link in my signature. It will show you how to give us the information we need to help you.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 02/13/2012 :  10:46:08  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Starts with BCP and format file. SQL Server help file has examples.

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 02/13/2012 :  10:51:22  Show Profile  Reply with Quote
Looks in SQL Server Books Online

However, when you use bcp you will need to have a file that defines how the output is suppose to look, that file is referenced by bcp with the switch

-f<filepath>\<filename>

Here's a sample


4
1       SQLSMALLINT   0       2       ""   1     EmployeeID               ""
2       SQLNCHAR      2       100     ""   2     Name                     SQL_Latin1_General_CP1_CI_AS
3       SQLNCHAR      2       100     ""   3     Title                    SQL_Latin1_General_CP1_CI_AS
4       SQLNCHAR      2       100     ""   4     Background               SQL_Latin1_General_CP1_CI_AS



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 02/13/2012 :  10:55:24  Show Profile  Reply with Quote
http://msdn.microsoft.com/en-us/library/ms191479.aspx



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Guruprasath.cub
Starting Member

India
8 Posts

Posted - 02/15/2012 :  09:57:56  Show Profile  Reply with Quote
Still, I could not get the answer. I need to make a report through asp code where the data in sql. The report should be a txt file in a fixed width delimited.
Anybody please help me
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 02/15/2012 :  10:01:21  Show Profile  Reply with Quote
from asp?

No

I can give you T-SQL commands

Are you using stored procedures?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000