Hi , I am new in this group
I have a simple question.
How can i create a TXT file from a SQL statement?
Something like this
Select * from table to Txtfile
is there any way?
Tks
Carlos Lages
Rio de JaneiroThis is something I've used before for a business case that needed me to create a text file with the latest primary key (sequential ID)
DECLARE @.sCmd varchar(256)
declare @.maxid varchar(12)
set @.maxid = (select max(pk) from test_tbl)
SET @.sCmd= 'echo>c:\temp\test.txt The new Primary Key is -' + @.maxid
EXEC master..xp_cmdshell @.sCmd, no_output
You can play with this and get what you need to throw to the text file or post back if you need help.
HTH|||rhigdon
tks
i will change to my needs , but i think will work fine
because what i realy need is select several fields from
several tables and create a txt file.
Carlos Lages|||THis article may be of help as well
http://www.sqlteam.com/item.asp?ItemID=4722
HTH
No comments:
Post a Comment