February 9, 2011 at 3:55 am
When i export with bcp to a *.csv file i get a non unique filename.
Example: myNativeFile.csv.
I like to get a date in my filename. Does anybody know a good method for this?
Maybe i kan design two scripts.
1. myNativeFile.csv for the import in Oracle (unicode)
2. myNativeFile20110209.csv for the archive
February 9, 2011 at 7:30 am
I advise using SSIS. You can set up filenames using expressions in SSIS and make it repeatable.
February 9, 2011 at 7:46 am
You can use variables in dynamic SQL. Here's a snippet:
SET @Cmd = 'BCP "SELECT * FROM ' + DB_NAME() + '.dbo.MyTable" queryout "' + @Folder + @FileName + @Extension + '" /c /T '
PRINT ' Executing xp_cmdshell: ' + CONVERT(varchar(1000), @Cmd)
EXEC master..xp_cmdshell @Cmd
February 9, 2011 at 10:17 am
Thanks guys, i will have a look at both solutions.
February 9, 2011 at 10:35 am
An additional note about SSIS, you can multicast the same data to do different destinations at the same time. That's one of the reasons why I like it for situations like this.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply