make a file txt | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

make a file txt

i need to do a file *.txt with a store procedure…sombody to help me please

Please explain, what you want to do import or export with *.txt files? _________
Satya SKJ

Here is the output for u create PROCEDURE AA
BEGIN DECLARE @result int
EXEC @result = MASTER..xp_cmdshell ‘bcp pomdb..pur_po_header out c:purpohdr.txt -n -SSERVERNAME -UUSERNAME -PPASSWORD’ , NO_OUTPUT
IF (@result = 0) PRINT ‘Success’ ELSE PRINT ‘Failure’ END
Note:- In the bcp the specified user should have atleast select permission on the table. For more details on BCP please see Sql server Books Online. Thanks Rushendra. Rushendra
Or if you simply need to write text to file (not export data)
alter Procedure WriteToFile
AS set nocount on
declare @command varchar(255)
select @command = rtrim(‘echo ‘ + COALESCE(LTRIM(@text),”) + CASE WHEN (@overwrite = 1) THEN ‘ > ‘ ELSE ‘ >> ‘ END + RTRIM(@filename))
EXEC master..xp_cmdshell @command
Ravlox could you please help all of us by answering satya’s question or reposting with a clearer explanation of the problem you are facing. The guessing game that is going on here might not be helpful to you and/or anybody else. Nathan H.O.
Ralvox sent email to me asking same question again! _________
Satya SKJ