gpt4 book ai didi

sql-server - VS SQLCLR : Function X has unresolved reference to schema Y

转载 作者:行者123 更新时间:2023-12-02 11:51:59 25 4
gpt4 key购买 nike

我正在使用 Visual Studio 2013 创建一个新的 SQL CLR,并在项目属性中将默认架构设置为“decASM”(原为“dbo”)。当我进行此更改并重建项目时,VS 会生成一个 sql 文件,如下所示:

--------------------------------------------------------------------------------
-- This code was generated by a tool.
--
-- Changes to this file may cause incorrect behavior and will be lost if
-- the code is regenerated.
--------------------------------------------------------------------------------

CREATE FUNCTION [decASM].[ExecFoxPro_SayHello] (@name [nvarchar](MAX))
RETURNS [nvarchar](MAX)
AS EXTERNAL NAME [dcFoxProAssy].[UserDefinedFunctions].[ExecFoxPro_SayHello];

GO

CREATE FUNCTION [decASM].[GetAllowedPaths] (@serviceUrl [nvarchar](MAX))
RETURNS [nvarchar](MAX)
AS EXTERNAL NAME [dcFoxProAssy].[UserDefinedFunctions].[GetAllowedPaths];

GO

CREATE FUNCTION [decASM].[GetTableRowCount] (@serviceUrl [nvarchar](MAX), @foxProPath [nvarchar](MAX), @tableName [nvarchar](MAX))
RETURNS [nvarchar](MAX)
AS EXTERNAL NAME [dcFoxProAssy].[UserDefinedFunctions].[GetTableRowCount];

GO

每次 CREATE FUNCTION 调用都会出现错误:

Error   1   SQL71501: Function: [decASM].[ExecFoxPro_SayHello] has an unresolved reference to Schema [decASM].  
Error 2 SQL71501: Function: [decASM].[GetAllowedPaths] has an unresolved reference to Schema [decASM].
Error 3 SQL71501: Function: [decASM].[GetTableRowCount] has an unresolved reference to Schema [decASM].

如果我将默认架构更改回“dbo”,则项目将成功构建。我已经搜索了项目属性和 Google,但找不到任何关于如何添加对“decASM”的引用的提及。

最佳答案

您还需要创建架构,作为单独的 SSDT 对象。仅通过指定您要将其用于 SQLCLR 对象,它不会自动为您创建。您应该能够:

  • 将新项目 (Control + Shift + A) 添加到项目的任意位置
  • 选择模板SQL Server> 安全性> 架构
  • 命名项目/文件:decASM
  • 保存并关闭脚本

它将在您的项目中为此创建一个单独的 SQL 文件,其中包含单个命令 CREATE SCHEMA [decASM],并将在您发布 SQLCLR 代码时部署它。

上面提到的步骤对我使用 Visual Studio 2013 确实有效。

关于sql-server - VS SQLCLR : Function X has unresolved reference to schema Y,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34770688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com