Tuesday, December 15, 2009

How to script SQL Server 2008 diagrams and restore them

I got a recent request of restoring diagrams from one database to another and found an awesome solution in here.

Sunday, December 13, 2009

What SQL Statements Are Currently Executing?

This is a fundamentally useful script.

Tuesday, December 1, 2009

How to grant execute permission of all stored procedures to a user?

One recent request from our testers is that they need to execute all stored procedures on the testing database. And the simplest solution is to create a database role which is granted the execute privilege and add the testers' database users into this role.

Here it goes the script:

use [testing_db]
go
create role [testers]
go

grant exec to [testers]
go

exec sp_addrolemember N'testers', N'tester_db_user_account'
go


By running the above script, not only the execute rights of stored procedures, but also those of scalar functions are granted to the user.

Here are the two links that you might find interesting as well regarding this topic:
1 and 2.