Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql Server permission for read-only user to prevent locks

In a SQL Server database, there is a table that has millions of records, that gets insert to and updated frequently with new data.

Now the client has requested that they write their own reports off this table.

I am very concerned about them not writing reports correctly and that they lock the table on a long running reports.

Can I give them credentials that cannot lock a table

I.e. Can only do dirty reads similar to WITH (NOLOCK)?

like image 588
Daryl Van Sittert Avatar asked Nov 28 '25 05:11

Daryl Van Sittert


1 Answers

I guess you could create a view over the table in question and add NOLOCK to that query. Then give their user account read only access to the view rather than the base table?

CREATE VIEW dbo.ReportingView
AS

SELECT COL1, COL2, COL3

FROM dbo.BASETABLE (NOLOCK)
like image 164
codingbadger Avatar answered Nov 30 '25 19:11

codingbadger