问题描述
我在 VS 2008 中使用SQL SERVER PROJECT"在 C# 中创建 UDF然后我使用 DEPLOY 命令将 DLL 发布到 MS SQL Server 2005
I'm using "SQL SERVER PROJECT" in VS 2008 to create UDF in C#Then I'm using DEPLOY command to publish DLL into MS SQL server 2005
除了所有创建的 UDF 都归我所有(作为用户)外,一切正常但我想保留 dbo 架构(例如:dbo.UDF_TEST - 不是 jonny.UDF_TEST)
All works well except all created UDFs are owned by me (as user)But I wanted to keep dbo schema (eg: dbo.UDF_TEST - not jonny.UDF_TEST)
知道如何管理塔尔吗?
推荐答案
我发现了另一种允许在 VS 内完成所有事情的方法.
I've found another approach allowing do everything inside VS.
我已将名为postdeployscript.sql"的 SQL 脚本添加到项目中:
I've added to project SQL script named "postdeployscript.sql":
声明@SQL NVARCHAR(200)
DECLARE @SQL NVARCHAR(200)
SET @SQL = 'alter schema dbo transfer' + CURRENT_USER +'.[UDF_GET_AUDIT_VALUE]'
SET @SQL = 'alter schema dbo transfer ' + CURRENT_USER +'.[UDF_GET_AUDIT_VALUE]'
执行(@SQL)
开始
脚本在解包过程中由 VS 自动执行,并将模式从当前用户更改为 DBO.
script is executed automaticcally by VS during depolyment process and changes schemas from current user to DBO.
缺点:您需要手动添加每个正在使用的 UDF/USP
Cons: you need to add each UDF/USP you are ceating manually
PS:请注意你也可以使用predeployscript.sql在部署前执行一些命令
PS: Please note you can also use predeployscript.sql to execute some commmands before deployment
这篇关于如何强制 dbo 架构名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!