sql-server – VS SQLCLR:函数X具有未解析的模式Y引用

我正在使用Visual Studio 2013创建一个新的sql CLR,并且在Project Properties中将Default Schema设置为’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’的引用.

解决方法

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

>在项目的任何位置添加新项目(控制班次A)
>选择模板sql Server>安全>架构
>命名项目/文件:decASM
>保存并关闭脚本

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

上面提到的步骤对我使用Visual Studio 2013很有用.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...