我正在使用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'的引用的提及。
答案 0 :(得分:19)
您还需要创建Schema,作为单独的SSDT对象。仅通过指定要将其用于SQLCLR对象,不会自动为您创建它。你应该能够:
decASM
它将在您的项目中为此创建一个单独的SQL文件,其中包含一个命令CREATE SCHEMA [decASM]
,并在您发布SQLCLR代码时将其部署。
上面提到的步骤对我使用Visual Studio 2013很有用。
答案 1 :(得分:0)