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
 Generate a .txt file

Author  Topic 

KEITHMCK
Starting Member

3 Posts

Posted - 2008-04-28 : 05:55:01
This is my first time on sqlteam forum so a big hello to everyone!!

Firstly I am very noive user of sql to say the least, but i have be requested to create a .txt file

Its for a program that will read the txt file i create to produce a letter i.e I will be extracting, TITLE, FORENAME, SURNAME etc

MR
JOE
BLOGGS

Here is the my code so far, like i said i am a very novice user so try to help me and not condem me for my lack of knowledge!

SELECT
LPA_INPUT.INPUT_TITLE,
LPA_INPUT.INPUT_SURNAME,
LPA_HISTORY.LPA_AMT,
LPA_HISTORY.ELIG_RATE,
LPA_HISTORY.RATE_REBATE,
LPA_HISTORY.RR_AMT,
LPA_HISTORY.LPA_APPLIC,
LPA_HISTORY.LPA_AMT
FROM LPA_HISTORY, LPA_INPUT
WHERE LPA_HISTORY.CLAIM_NO = LPA_INPUT.CLAIM_NO
----------------------------------------------------
Iv been asked to have these eight fields looping over and over for all the records in the database, So im not to how to do that and how to generate it in a txt file?!

Keith

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-28 : 06:03:45
Use Export/Import wizard by using the above query as source query. You can find export/import wizard in enterprise manager in sql 2000 and sql server mangement studio in sql 2005
Go to Top of Page

KEITHMCK
Starting Member

3 Posts

Posted - 2008-04-28 : 06:06:15
sorry gorgot to add:

I have to do it by writin it in sql script
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-28 : 06:11:27
Try using OPENDATASOURCE. look into books online for syntax.
Go to Top of Page

KEITHMCK
Starting Member

3 Posts

Posted - 2008-04-28 : 06:16:29
Hey thanks very much - jus googled

OPENDATASOURCE - Provides ad hoc connection information as part of a four-part object name without using a linked server name.

How does this help me? but i have been asked for a script to produce the request above!!! (like i said im very new to this)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-28 : 12:58:52
this discusses one of method using bcp:-

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/bcp-export-data-to-text-file.aspx
Go to Top of Page
   

- Advertisement -