Autotask PSA SQL 查询错误

Autotask PSA SQL 查询错误

.BAK我们向 Autotask(现为 Datto)支付了 150 美元,以备份/导出我们的 PSA 数据,他们以 SQL 数据库文件的格式提供这些数据。

我们需要从 Autotask PSA 资产的用户定义字段 (UDF) 中提取数据,因此在一次性 VM 中,我有:

  1. 安装了 Microsoft SQL Server 2017 Express(最新)和 Microsoft SQL Server Management Studio (SSMS)。
  2. 使用 BAK 文件恢复数据库。
  3. 确定可以使用视图检索我们需要的数据dbo.wh_installed_product_udf
  4. 发现执行查询select * from wh_installed_product_udf/select * from dbo.wh_installed_product_udf失败并出现以下错误消息:

 

Msg 4121, Level 16, State 1, Procedure wh_installed_product_udf, Line 1 [Batch Start Line 0]
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnSafeNumericConvert", or the name is ambiguous.

Msg 4413, Level 16, State 1, Line 1
Could not use view or function 'wh_installed_product_udf' because of binding errors.

我无法在网上找到解决方案,因此发表了这篇文章。

答案1

我们确定根本原因是由于fnSafeNumericConvert某种原因依赖函数不再存在,并通过在 SSMS 中执行以下操作来解决这个问题:

  1. 右键单击视图dbo.wh_installed_product_udf→ 单击Design
  2. 复制查询(SELECT等等)。
  3. 删除所有包含以下内容的行fnSafeNumericConvert(在我们的例子中为MAX(CASE udf_value_installed_product.udf_field_id WHEN 29682891 THEN dbo.fnSafeNumericConvert(decimal_value) ELSE NULL END) AS Number_of_Licenses_as_numeric,)。
  4. 手动执行剩余的查询。

相关内容