BCP工具过滤数据表的有关问题,请各位大神帮忙看下!全部分奉上

BCP工具过滤数据表的问题,请各位大神帮忙看下!全部分奉上!
用BCP工具导出数据表,默认的是全部导出,现在需要做修改,需要过滤导出表。脚本应该怎么修改呢、?

大概思路所有需要导出的表放在一个配置文件里面,读取配置文件,给个列表,然后按照列表来导出。

请大神们帮忙看下,谢谢了!

下面是BCP工具脚本select_allDB_table_Ms.sql的代码:

SQL code

EXEC sp_configure 'show advanced options', 1
GO
-- 重新配置
RECONFIGURE
GO
-- 启用xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
GO
--重新配置
RECONFIGURE
GO
create proc sp_test @path varchar(255),@svrname varchar(255),@username varchar(255),@password varchar(255),@indbname varchar(255)
as
select * from sysdatabases where dbid > 6

declare @dbname varchar(255)
declare @tablename varchar(255)
declare @cmdline varchar(255)

declare @creatpath varchar(255)
select @creatpath = 'md ' + @path
exec master..xp_cmdshell @creatpath

exec ('declare all_cursor cursor
for select name from sysdatabases where dbid > 6 and upper(name) like ''%'+@indbname+'%''')


open all_cursor
fetch all_cursor into @dbname

while @@fetch_status = 0
begin
    
   print @dbname
   select @cmdline = 'md ' + @path + '\'+ @dbname 
   exec master..xp_cmdshell @cmdline
   exec ('declare tbl_cursor cursor for
   select name from ' + @dbname +'.dbo.sysobjects where xtype = ''U''')
   
   open tbl_cursor
   fetch tbl_cursor into @tablename
   while @@fetch_status = 0
   begin
    print @tablename
    select @cmdline = 'bcp "'+ @dbname + '..' + @tablename + '" out "' + @path + '\' + @dbname + '\' +@tablename + '.txt" -c -U' + @username +' -P'+@password  +' -S ' + @svrname
        print @cmdline
        exec master..xp_cmdshell @cmdline
        fetch tbl_cursor into @tablename
   end
   close tbl_cursor
   deallocate tbl_cursor
   fetch all_cursor into @dbname
end
close all_cursor
deallocate all_cursor

GO




------解决方案--------------------
不知道耶,你是想用python写一个脚本,按配置导出表吗?这个sql只是给做参考的吧