Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql table to fixed width text file output

Author  Topic 

Guruprasath.cub
Starting Member

8 Posts

Posted - 2012-02-13 : 06:16:59
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
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-02-13 : 07:50:41
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

22864 Posts

Posted - 2012-02-13 : 10:46:08
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 - 2012-02-13 : 10:51:22
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 - 2012-02-13 : 10:55:24
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

8 Posts

Posted - 2012-02-15 : 09:57:56
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 - 2012-02-15 : 10:01:21
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
   

- Advertisement -