【问题标题】:Update Extended Properties of a Stored Procedure更新存储过程的扩展属性
【发布时间】:2015-09-17 13:35:13
【问题描述】:

这里的 SQL 中的 Dummy 需要更新存储过程的扩展属性。只能找到更新表格内容的信息,而不是属性。

需要从 C# 函数向数据库发送查询。

它会读起来像;

string query = "Update StoredProcedureName SET caption = 'newValue' WHERE caption = 'oldValue' "

其中标题是扩展属性的名称。

【问题讨论】:

    标签: sql .net sql-server database updates


    【解决方案1】:

    您可以在此处找到有关如何更新扩展属性的信息

    https://msdn.microsoft.com/en-us/library/ms186885.aspx

    示例:

    string query = "EXEC sp_updateextendedproperty  ";
    query += "     @name = N'Caption'  ";
    query += "     ,@value = 'newValue.'   "; 
    query += "     ,@level0type = N'Schema', @level0name = dbo    ";
    query += "     ,@level1type = N'Procedure',  @level1name = STOREDPROCNAME    ";
    query += "     ,@level2type = N'Property', @level2name = Caption;    ";
    

    而不是像以前那样将查询发送到数据库

    【讨论】:

    • 看起来很到位。这是否意味着类似的东西。 UPDATE Database.StoredProcedure EXEC sp_updateextendedproperty @name = N'Caption' ,@value = 'newValue.' GO ?
    • @beatsandbosons 我已经编辑了我的答案,希望现在更清楚
    • 看看我的答案中的链接,它将更详细地解释它
    • 我明白了。那么,理论上在存储过程本身中运行EXEC sp_updateextendedproperty @name = N'Description' ,@value = 'Test success.' ,@level0type = N'Schema', @level0name = dbo ,@level1type = N'Table', @level1name = T1 ,@level2type = N'Column', @level2name = id; 应该将扩展属性“描述”值更改为“测试成功”?似乎没有按原样工作。可能需要对自己进行更多的教育。不过感谢您的提示。
    • 再次编辑了我的答案,但你应该看看链接。您需要将 Level1type 更改为 N'Procedure',@Level1name = procname。还没有测试过,但是这个和链接应该让你朝着正确的方向前进
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    • 2011-02-21
    • 1970-01-01
    相关资源
    最近更新 更多