I want to find all columns of a table which have "read-only" access for some analysis.
how do can this be done in SQL Server?
I tried following but its not giving me desired results:
SELECT OBJECT_NAME(id) as ObjectName, Name as ComputedColumn
FROM syscolumns
WHERE COLUMNPROPERTY( id ,name, 'SystemDataAccess') = 0
AND name like 'my_table_name'
2条答案
按热度按时间puruo6ea1#
If you mean "Read-Only" in the all users perspective (as in under normal circumstances nobody should be able to write to the column regardless of user specific access) the below type of thing could be used to return the columns that are identity or computed values (I can't think of any other specific cases where you cannot write to a column)...
v1uwarro2#
A similar solution without the JOIN: