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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I create a text file from SQL?

Status
Not open for further replies.

cmdematos

IS-IT--Management
Mar 7, 2001
29
US
I want to create a text file from SQL - something like this..

DECLARE @A_FLD AS CHAR(5), @B_FLD AS CHAR(7)

SET @A_FLD = 'HI'
SET @B_FLD = 'MOM'

EXEC xp_<?????> FILENAME, @A + @B + '!'

The result must be...

'HI...MOM....!' in the text file.

Is there a simple way short of building an active-x control for this need?

 
How about a good old DOS echo:

EXEC master..xp_cmdshell echo @a >log.txt,no_output
EXEC master..xp_cmdshell echo @b >>log.txt,no_output

>> = append
> = rewrite
 

DECLARE @A_FLD AS CHAR(5), @B_FLD AS CHAR(7)
DECLARE @CMD VARCHAR(60)

SET @A_FLD = 'HI'
SET @B_FLD = 'MOM'
SET @CMD='Echo ' + @A_FLD + @B_FLD + '! > C:\temp\testing.txt'
EXEC xp_cmdshell @CMD Terry Broadbent
Please review faq183-874.

&quot;The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge.&quot; - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top