我很难理解你的问题。
我也可以以某种方式只允许用户更新某些字段而不是其他字段吗?
简短的回答是的。以下示例在 User007 的 Name 列上授予 UPDATE 并在 OrganizationNode 列上拒绝 UPDATE。
GRANT SELECT ON dbo.Department TO User007;
GRANT UPDATE (Name) ON dbo.Department TO User007;
DENY UPDATE (OrganizationNode) ON dbo.Department TO User007;
GO
现在您可以使用此用户进行连接并执行以下语句:
PRINT 'SELECT >';
SELECT *
FROM dbo.Department;
PRINT 'UPDATE #1 >';
UPDATE dbo.Department
SET Name = NULL;
PRINT 'UPDATE #2 >';
UPDATE dbo.Department
SET OrganizationNode = NULL;
PRINT 'End of Test';
GO
结果:
SELECT >
DepartmentID Name OrganizationNode
------------ -------------------------------------------------- ------------------------------------------------------------
UPDATE #1 >
UPDATE #2 >
Msg 230, Level 14, State 1, Line 13
The UPDATE permission was denied on the column 'OrganizationNode' of the object 'Department", database 'Test', schema 'dbo'.