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
»
Administering
»
Replacing Schema with new schema of Database...
Replacing Schema with new schema of Database objects
Rate Topic
Display Mode
Topic Options
Author
Message
pramod_patnaik
pramod_patnaik
Posted Wednesday, July 01, 2009 12:45 PM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, August 02, 2009 2:06 PM
Points: 1,
Visits: 6
Hi,
I have a schema called "Emp" and all the tables binds to this schema. Now I have created a new schema called "Employee" and wants to bind this new schema "Employee" instead of "Emp". How can I do this with minimal effort.
Also old schema "Emp" is used in my stored procedure and views with tables. I also wants to replace in those stored proc and views.Is there any good script/tool is available for this.
Thanks..
Post #745698
hi_abhay78
hi_abhay78
Posted Thursday, July 02, 2009 12:53 AM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, July 26, 2012 10:06 AM
Points: 267,
Visits: 385
This is your answer my friend :)
sp_msforeachtable 'ALTER SCHEMA test TRANSFER ?'
this will change the schema to test .You can change it to employee.
make sure you are in the right database context.
Regards
Abhay Chaudhary
Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)
Post #746020
Jack Corbett
Jack Corbett
Posted Thursday, July 02, 2009 8:10 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 3:07 PM
Points: 10,613,
Visits: 11,959
Whenever I recommend using sp_MSForEachTable I always include a link to
this article
which explains the parameters of the procedure and how it works.
I would script out all my procedures, functions, and views and then do a search and replace to change Emp. to Employee.
Jack Corbett
Applications Developer
Don't let the good be the enemy of the best. --
Paul Fleming
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #746298
hi_abhay78
hi_abhay78
Posted Thursday, July 02, 2009 8:46 PM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, July 26, 2012 10:06 AM
Points: 267,
Visits: 385
Nice one Jack ....
Cheers
Abhay Chaudhary
Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)
Post #746734
SQLQuest29
SQLQuest29
Posted Friday, July 03, 2009 12:23 PM
Say Hey Kid
Group: General Forum Members
Last Login: Today @ 10:31 AM
Points: 713,
Visits: 2,974
Hi,
Try this:
set the o/p mode to text in SSMS .. then run the following .....
SELECT 'ALTER SCHEMA Employee TRANSFER ' + TABLE_SCHEMA + '.' + TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'EMP'
sp_msforeachtable
this is an undocumented procedure ... it is very handy but not recommended by Microsoft.
Also old schema "Emp" is used in my stored procedure and views with tables. I also wants to replace in those stored proc and views.Is there any good script/tool is available for this.
I would go with what Jack suggested ....
I would script out all my procedures, functions, and views and then do a search and replace to change Emp. to Employee.
Hope this helps ...
Happy 4th of JULY !
Thanks,
\\K
HTH,
Cheers !
"Never take life too seriously, nobody gets out of it anyways !
When your love and skills unite, expect a masterpiece !"
Post #747081
« 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.