如何在bcp命令sql server中添加多个查询

时间:2014-04-10 09:26:47

标签: sql-server

我在bcp命令中传递了以下查询,并且由于多个查询而未执行该命令

bcp  " SET NOCOUNT ON;IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[primaryKeys]') AND type in (N'U'))     SELECT primary_key_name,[schema_name],table_name,column_name,successfully_removed ,successfully_readded,alter_command_drop ,alter_command_add FROM primaryKeys"  c:\Testing.xls -c -STest -dMydb -Usa -PPassword1

请帮忙

1 个答案:

答案 0 :(得分:0)

您错过了queryout选项:

bcp  "SET NOCOUNT ON;IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[primaryKeys]') AND type in (N'U'))     SELECT primary_key_name,[schema_name],table_name,column_name,successfully_removed ,successfully_readded,alter_command_drop ,alter_command_add FROM primaryKeys" quryout c:\Testing.xls -c -STest -dMydb -Usa -PPassword