October 3, 2011 at 12:07 pm
Hi,
I need to export 9 sql server tables data to pipe delimited text file.
I tried to use import/export wizard, but I can't export more than one table at a time.
So just wondering is there any BCP script that I can use for export all 9 at a time.
Appreciate your help.
Thanks.
October 3, 2011 at 12:32 pm
laddu4700 (10/3/2011)
Hi,I need to export 9 sql server tables data to pipe delimited text file.
I tried to use import/export wizard, but I can't export more than one table at a time.
So just wondering is there any BCP script that I can use for export all 9 at a time.
Appreciate your help.
Thanks.
might need more info...9 separate files, one for each table, or one file with the content of those 9 files?
if it's 9 files, it's 9 commands. if it's one file, assuming they all have the same strucuture, it would be one command, using queryout, and a query like SELECT [ColumnList] from table1 UNION ALL SELECT [ColumnList] from table2...etc
--example of the pipe char as a delimiter
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT object_name(object_id) As TbLName,name as ColName FROM SandBox.sys.columns ORDER BY object_name(object_id), column_id" queryout C:\Data\Objects.txt -t"|" -c -T '
Lowell
October 3, 2011 at 12:44 pm
9 tables - 9 pipe delimited file, separate for each table
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply