Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Drop and recreate stored procedures

Author  Topic 

Sean Frost
Starting Member

19 Posts

Posted - 2009-12-30 : 10:50:53
I need to drop and recreate a few dozen stored procedures. However, when I experimented doing that with one stored procedure, it recreated the procedure itself correctly, but blew away all the permissions on it. Is there a way to script a stored procedure along with the permissions so I can drop and then recreate it including the permissions?

The reason I need to do this that I have to extend a TVP to add another column. There does not seem to be a way to simply alter the TVP; I have to drop and recreate it. But then, it wouldn't let me drop the TVP because the stored procedures depend on the TVP. So I am thinking of dropping all the stored procedures, modifying the TVP and then recreating the stored procedures. If there is another way to do this, please let me know. Luckily for me, the stored procedures themselves would not be affected by the additional column in the TVP.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-30 : 10:58:39
Permissions can be included if you script through the wizard.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Sean Frost
Starting Member

19 Posts

Posted - 2009-12-30 : 11:13:11
I searched through the menus in management studio - can't find where to launch the wizard from! help!?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-30 : 11:15:13
It's the "Generate Scripts..." option under "Tasks" menu item when you right-click on the database.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Sean Frost
Starting Member

19 Posts

Posted - 2009-12-30 : 11:16:11
please ignore my last message. Found it. (right click database in object explorer, then tasks, generate scripts. Thanks tkizer!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-30 : 11:21:47
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -