我正在使用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对象,它不会为您自动创建。你应该能够:
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/