Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I generated a script from the old database, created a new database and imported all data from the old database. So far so good, however, no user has executed rights for stored procedures. I know I can use

GRANT EXECUTE ON [storedProcName] TO [userName] 

If it was just a few procedures, however, I have about 100 so what's the easiest way for me to grant execute access for a specific user to all of them?

Thanks in advance.

1 Answer

0 votes
by (40.7k points)

Create a role add this role to users, and then you can grant execute to all the routines in one shot to this role like this:

CREATE ROLE <abc>

GRANT EXECUTE TO <abc>

EDIT

The above code will work in SQL Server 2005, I'm not sure about the backward compatibility of this feature, I'm sure anything later than 2005 should be fine.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...