문제

I'm trying to create a persistent SQL (SQL Server 2005) lock on a table level. I'm not updating/querying the specified table, but I need to prevent a third party application from updating the locked table as a means to prevent transactions from being posted (the table I wish to lock is the key on their transaction that interferes with my processing).

From my experience the table is only locked for the time a specific transaction is taking place. Any ideas?

The 3rd party developer has logged this feature as an enhancement, but since they are in the middle of rolling out a major release I can expect to wait at least 6 months for this. I know that this isn't a great solution, since their software will fall over but it is of a critical enough nature that we're willing to live with the consequences.

도움이 되었습니까?

해결책

Move the table to a different file group, then alter the file group to read-only. The table will be in effect read-only:

ALTER DATABASE dbName 
   ADD FILEGROUP ReadOnlyFG;
GO

ALTER DATABASE dbName 
   ADD FILE (
    NAME = ...,
    FILENAME = '...')
   TO FILEGROUP ReadOnlyFG;
GO

ALTER TABLE tableName MOVE TO ReadOnlyFG;
GO

ALTER DATABASE dbName
   MODIFY FILEGROUP ReadOnlyFG READONLY;

다른 팁

rename the table and when the 3rd party is ready rename it back to what it should be

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top