Can anyone please tell me how to export data from a sql database to an ascii text file ?
Export
Collapse
X
-
-
For a simple technique, use this .
You have to run the bcp through xp_cmdshell, so watch out for proper access rights. You might also want to consider making this command dynamic to have a more dynamic file name of your text file.
And watch for existing filename, non-existing destination folder, etc...
-- CKComment
-
Thankyou very much, i will take a look at this. :DOriginally posted by ck9663For a simple technique, use this .
You have to run the bcp through xp_cmdshell, so watch out for proper access rights. You might also want to consider making this command dynamic to have a more dynamic file name of your text file.
And watch for existing filename, non-existing destination folder, etc...
-- CKComment
-
when i use the bcp it saysOriginally posted by OuTCasTThankyou very much, i will take a look at this. :D
Error=[MICROSOFT][SQL Native Client]Unable to open BCP host data file
this is the code
[CODE=sql]declare @filename varchar(50),
@bcpCommand varchar(2000)
SET @filename = REPLACE('c:\pro ducts_'+convert (char(8),GETDAT E(),1)+'.txt','/','-')
SET @bcpCommand = 'bcp "SELECT * FROM PUBS..Authors" queryout "'
SET @bcpCommand = @bcpCommand = @filename + ' " -T -c -S [servername]'
exec master..xp_cmds hell @bcpCommand[/CODE]Comment
Comment