Thursday, 19 November 2015

Stop People From Changing Tables with This One Trick

I received today's posts from Brent Ozar, I feel it is very interesting, LOL:


Brent Ozar says:
Stop People From Changing Tables with This One Trick

Brace yourselves. Our Black Friday sale is coming.
Developers hate his bad idea jeans:
CREATE VIEW dbo.StopThemDead WITH SCHEMABINDING
AS
SELECT COUNT(*) FROM dbo.Table1
UNION ALL
SELECT COUNT(*) FROM dbo.Table2
UNION ALL....
Presto, the schemabinding option means no one can change the underlying tables. (At least, until they figure out about your view.)
Obligatory disclaimer: seriously, this is a really bad idea. But it’s hilarious.

No comments:

Post a Comment