从 SQL Server 表中选择扩展属性
我正在为客户的数据库编写一个简单的 CMS。有 12 个表,他们需要管理其中 4 个表中的所有数据。
我设置了一个动态数据项目(Linq-to-SQL,因为这是我最熟悉的),并且第一页使所有 12 个表都可按其应有的方式进行编辑。它们位于名为visibleTables 的可枚举列表中。
接下来,我进入 SSMS 并创建一个名为 UserEdit 的扩展属性,并将其设置为 0 或 1,具体取决于用户是否应该在该屏幕上看到它。
我想做的是通过扩展属性过滤visibleTables列表,但不知道如何做。
我可以使用此查询查看表和属性的列表:
select major_id, name, value
from sys.extended_properties
where name = 'UserEdit'
我打算循环遍历visibleTables并删除带有0的表,但我还没有弄清楚,因为major_id似乎不是我能找到的财产。
I am writing a simple CMS for a client's database. There are 12 tables and they need to manage all of the data in 4 of them.
I set up a dynamic data project (Linq-to-SQL as that's what I'm most familiar with) and the first page makes all 12 tables available for edit as it should. These are in an enumerable list called visibleTables.
Next I went into SSMS and created an extended property called UserEdit and set it to 0 or 1 depending on whether the user should see it on that screen.
What I would love to do is filter the visibleTables list by that extended property but don't know how to.
I am able to see the list of tables and the property with this query:
select major_id, name, value
from sys.extended_properties
where name = 'UserEdit'
and I was going to loop through the visibleTables and remove the ones with 0s but I haven't figured that out either yet as the major_id doesn't seem to be a property I can find.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对我来说工作...
This work for me...
好吧,根据 http://msdn.microsoft.com/en-us/library /ms177541.aspx,扩展属性类 (OBJECT_OR_COLUMN) 的“major_id”实际上表示“object_id”。因此,以下查询将为您提供所有扩展属性以及它们所属的表:
您可以根据需要对其进行过滤,但如果您需要帮助,请告诉我。
Well, according to http://msdn.microsoft.com/en-us/library/ms177541.aspx, "major_id" for your class of extended properties (OBJECT_OR_COLUMN) really indicates the "object_id". So the following query would get you all the extended properties along with the tables they belong to:
You can filter it as you like, but let me know if you need help.