Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 General Discussion
»
Change schema in stored procedure
Change schema in stored procedure
Rate Topic
Display Mode
Topic Options
Author
Message
manoharanpraveen
manoharanpraveen
Posted Monday, December 27, 2010 5:24 PM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, July 26, 2011 11:52 AM
Points: 15,
Visits: 94
Hello
I have a bunch of stored procedure(more than 200) in my database.
I have to change the schema of those now. They have the schema ABC. I have to change it to XYZ,.
I know [ALTER SCHEMA XYZ TRANSFER ABC.STOREDPROCEDURE] query would do.
But the no of stored procedure is huge . I cannot do one by one. Is there any other way to do this task.
thanks
Post #1039605
Grant Fritchey
Grant Fritchey
Posted Tuesday, December 28, 2010 8:04 AM
SSChampion
Group: General Forum Members
Last Login: Yesterday @ 9:14 PM
Points: 13,381,
Visits: 25,174
Export the stored procedures out to a script or set of alter scripts. Make the changes in the scripts. Run the scripts against the server.
For a mechanism to automate this you might look at Red Gate's tool,
SQL Prompt
, which has a bunch of automatic refactoring mechanisms, just like this.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1039781
nekonecny
nekonecny
Posted Tuesday, December 28, 2010 8:13 AM
SSC Rookie
Group: General Forum Members
Last Login: Friday, May 03, 2013 7:12 AM
Points: 27,
Visits: 363
declare @name sysname
select top 1 @name=SPECIFIC_NAME from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE='PROCEDURE' AND ROUTINE_SCHEMA='ABC'
while (@name is not null)
begin
execute( 'ALTER SCHEMA XYZ TRANSFER ABC.' + @name);
select top 1 @name=SPECIFIC_NAME from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE='PROCEDURE' AND ROUTINE_SCHEMA='ABC'
End
Post #1039793
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.