在 SSMS 2008 中向用户授予权限时复制脚本?

发布于 2024-12-01 04:38:34 字数 1117 浏览 2 评论 0原文

在 MS SQL 2008 Management Studio 中,我试图拒绝特定用户使用表中的某些列/字段。

为此,我右键单击数据库,展开“安全”,然后展开“用户”。 选择相关用户后,右键单击并选择“属性”。

下一步是选择“Securables”页面,然后选择“Select”权限。接下来,单击“列权限”

在此处输入图像描述

一旦我选择了要拒绝的字段访问所选用户的权限,然后点击“脚本”,这样我就可以在新的查询窗口中看到 T-SQL(您可以参考上面的同一张图片。脚本位于窗口的顶部)。

所以这是我的问题:生成的脚本似乎将每个操作重复两次。 例如,它看起来像这样:

use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DatabaseConnectionString]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBUserName]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBPassword]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DatabaseConnectionString]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBUserName]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBPassword]) TO [Testing_Login]
GO

知道为什么这样做吗?我们有许多表,我想要匹配它们的权限,并且正在考虑使用 CURSOR 来执行此操作。但我不知道是否应该在我的程序中包含上述脚本,或者删除重复的语句是否安全。

请告诉我您的想法。

谢谢

In MS SQL 2008 Management Studio, I'm trying to deny certain columns/fields in a table to a specific user.

To do this, I right click on the DB, expand "Security" and then expand "Users".
Once I've selected the user in question, I then right click and choose "Properties".

The next step is to then choose the page "Securables" and then choose the "Select" Permission. This is followed by clicking on "Column Permissions"

enter image description here

Once I've chosen the fields that I want to deny access to for the selected user, I then hit Script, so I can see the T-SQL in a new query window (you can refer to the same image above. The Script is on the top of the window).

So here's my question: the resulting script seems to duplicate each action twice.
For example, here's what it looks like:

use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DatabaseConnectionString]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBUserName]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBPassword]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DatabaseConnectionString]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBUserName]) TO [Testing_Login]
GO
use [master_table]
GO
DENY SELECT ON [dbo].[Table_Main] ([DBPassword]) TO [Testing_Login]
GO

Any idea why it does this? We have a number of tables that I want to match the permissions for and was thinking of using a CURSOR to do this. But I don't know if I should include the above script as is in my procedure or if it's safe to remove the duplicate statements.

Please let me know what you think.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残疾 2024-12-08 04:38:34

我在 SSMS 2008 R2 中尝试了相同的操作,并为表中的每一列获得了相同的重复脚本。看来是SSMS的问题。我不明白为什么您需要包含重复的脚本。我建议你可以忽略它们。

您可能需要在 Microsoft Connect 网站报告此问题。

貌似网站上也有类似的问题报告。它仍然被列为活动状态。

SSMS 脚本操作生成 2 ALTER DATABASE 语句

I tried the same in SSMS 2008 R2 and got the same duplicate scripts for each column in the table. It seems to be an issue with SSMS. I don't see any reason why you need to include the duplicate script. I would suggest that you can ignore them.

You might want to report this issue at Microsoft Connect website.

Looks like there was a similar issue report at the website. It is still listed as Active.

SSMS Script Action produces 2 ALTER DATABASE statements

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文