|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:39 PM
Points: 6,260,
Visits: 1,977
|
|
Ninja's_RGR'us (2/3/2009) I think I'd go with the instead of triggers... if it saves me a full clustered index rebuild.
True but like with every thing there is an "it depends" :D
You will be kicking people out AFTER the "inserted" and "deleted" tables are created on tempdb. It "could" become a PIG! In SQL 2000 inserted and deleted tables were built directly from the transaction log ... not any more ;)
* Noel
|
|
|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Today @ 3:18 AM
Points: 21,359,
Visits: 9,541
|
|
Ah!, learn something new everyday :P.
That's a good it depends. There would need to have a buttload of traffic on that table to cause tempdb to crash or become a hotspot (unless it's already hot and getting worse because of that).
P.S. Just remember to deactivate the trigger before doing your big table load... that could really make a hot-spot of the server!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:01 AM
Points: 7,111,
Visits: 7,185
|
|
noeld (2/3/2009) Actually I have had the need for this feature for a long time. Suppose you need to prevent changes on ONE table while you are doing some maintenance work in a Db. To Set a DB in read-only mode is too drastic, To Setup that table in a separated File and make it read only is inconvenient. To setup INSTEAD OF/AFTER TRIGGERS is expensive in Server resources.
This solution seems cheap and Fast ;)
It seems expensive to me, re-ednabling the clustered index implies rebuilding every index on the table. If the DB design is reasonable, there are a maybe a small number of roles which have permissions on this table - altering those permissions seems pretty cheap and easy (and also provides the option of making the table read only, which is a little less drastic than making it completely inaccessible - particularly if your objective is, as you suggest, just to prevent changes).
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:39 PM
Points: 6,260,
Visits: 1,977
|
|
Tom.Thomson (2/3/2009)
noeld (2/3/2009) Actually I have had the need for this feature for a long time. Suppose you need to prevent changes on ONE table while you are doing some maintenance work in a Db. To Set a DB in read-only mode is too drastic, To Setup that table in a separated File and make it read only is inconvenient. To setup INSTEAD OF/AFTER TRIGGERS is expensive in Server resources.
This solution seems cheap and Fast ;)
It seems expensive to me, re-ednabling the clustered index implies rebuilding every index on the table. If the DB design is reasonable, there are a maybe a small number of roles which have permissions on this table - altering those permissions seems pretty cheap and easy (and also provides the option of making the table read only, which is a little less drastic than making it completely inaccessible - particularly if your objective is, as you suggest, just to prevent changes).
That sounds nice when you control the code.
* Noel
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:39 PM
Points: 6,260,
Visits: 1,977
|
|
Oh And I have seen *MANY* people using simply db_datareader and db_datawriter. You could take those permissions away and then the "entire" DB is inaccessible 
* Noel
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Friday, May 17, 2013 11:21 AM
Points: 4,317,
Visits: 9,216
|
|
Tom.Thomson (2/3/2009) It seems expensive to me, re-ednabling the clustered index implies rebuilding every index on the table.
With SQL Server 2005 and greater, rebuilding the clustered index does not force a rebuild of all NC indexes.
Jeffrey Williams Problems are opportunites brilliantly disguised as insurmountable obstacles.
How to post questions to get better answers faster Managing Transaction Logs
|
|
|
|