简体   繁体   English

通过SQL Server代理作业执行SSIS包时出错

[英]Error when executing SSIS package through SQL Server Agent job

I need to find a way to create a backup of a table's schema. 我需要找到一种创建表模式备份的方法。 I've been trying to do so using a Transfer SQL Server Object, but I don't see how you can specify the specific source and destination table to copy the schema to/from when using this type of control flow item in a package. 我一直在尝试使用传输SQL Server对象来执行此操作,但是当在包中使用这种类型的控制流项目时,我看不到如何指定特定的源表和目标表来将架构复制到该表中。 Once I can figure this out, I will be scheduling this to run automatically. 一旦弄清楚了,我将安排它自动运行。 I would appreciate any assistance with this. 我将不胜感激。 Thanks! 谢谢!

Update 更新资料
Thanks, all. 谢谢大家 I have the following problem - I have the Transfer SQL Server Objects control flow item working when executing from Visual Studio, and it is copying the table structure from one server/database to another server. 我有以下问题-从Visual Studio执行时,我有“传输SQL Server对象”控制流项目正在工作,并且它正在将表结构从一个服务器/数据库复制到另一台服务器。 I have created this as an SSIS package and imported it onto the original server (the one having the table structure copied), however, when trying to run the package job, I keep getting the error saying, "Failed to connect to server...there were errors during task validation...package execution returned DTSER_FAILURE (1)...the step failed." 我已将其创建为SSIS程序包,并将其导入到原始服务器(已复制表结构的服务器)中,但是,当尝试运行该程序包作业时,我不断收到错误消息:“无法连接到服务器。在任务验证期间发生错误...程序包执行返回DTSER_FAILURE(1)...此步骤失败。” Does anyone have any idea of why it would run fine in Visual Studio, but not as a job? 有谁知道为什么它可以在Visual Studio中正常运行,但不能作为工作吗?

Bit late, but maybe this answer will help someone else. 有点晚了,但是也许这个答案会帮助别人。 There are (at least) two things that can cause an execution difference between you executing the package in BIDS and SQL Server running the package through a job. 在BIDS中执行程序包和通过作业运行程序包的SQL Server之间,至少有两件事会导致执行差异。

1) The package protection level in BIDS package project 1)BIDS打包项目中的打包保护级别
The ProtectionLevel property of your package is set to one of the following values: 包的ProtectionLevel属性设置为以下值之一:

  • DontSaveSensitive 不保存敏感
  • EncryptSensitiveWithUserKey EncryptSensitiveWithUserKey
  • EncryptSensitiveWithPassword EncryptSensitiveWithPassword
  • EncryptAllWithPassword EncryptAllWithPassword
  • EncryptAllWithUserKey EncryptAllWithUserKey
  • ServerStorage 服务器存储

The default value is for some insane reason EncryptSensitiveWithUserKey . 由于某些疯狂的原因,默认值是EncryptSensitiveWithUserKey This means that sensitive information in the package is encrypted based on the credentials of the user who created the package. 这意味着将根据创建软件包的用户的凭据对软件包中的敏感信息进行加密。 This also means that if another user (someone who did not create and save the package) opens or runs the package you get an error - that is, if there is any sensitive information in the package. 这也意味着,如果另一个用户(未创建并保存该程序包的人)打开或运行该程序包,则会出现错误-也就是说,该程序包中是否包含任何敏感信息。

So you want to change this default value to something more sensible like DontSaveSensitive (our standard value) or EncryptSensitiveWithPassword . 因此,您想将此默认值更改为更合理的名称,例如DontSaveSensitive (我们的标准值)或EncryptSensitiveWithPassword

2) The executing account in SQL Server Agent job 2)SQL Server代理作业中的执行帐户
The standard value for the Run as field in the Job Step window is the SQL Server Agent Service Account . “作业步骤”窗口中“ 运行方式”字段的标准值为SQL Server代理服务帐户 This account is configured when SQL Server is installed and permissions depend on the account that was chosen. 在安装SQL Server时配置此帐户,并且权限取决于所选的帐户。

SQL Server作业步骤

So it could be the case that this account does not have permission to do something that is defined in your package. 因此,可能是该帐户无权执行您的软件包中定义的操作。 Connect to another database server, for example. 例如,连接到另一个数据库服务器。

You can choose another account to run the package, by setting up a proxy. 您可以通过设置代理来选择另一个帐户来运行该程序包。 More information on this can be found elsewhere on StackOverflow, see here for example. 可以发现它的更多信息StackOverflow上的其他地方,看到这里的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM