SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to change the schema prefix for a table when using Transfer SQL Server Objects Task


How to change the schema prefix for a table when using Transfer SQL Server Objects Task

Author
Message
dndaughtery
dndaughtery
SSC Eights!
SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)

Group: General Forum Members
Points: 874 Visits: 1086
I am wanting to use Transfer SQL Server Objects Task to copy tables and their data from one database to another but the hitch is that where the table is in the dbo schema in the source database but it needs to be on another schema on the destination. I know I can copy them over using the dbo schema and run tsql to update the schema but how do I handle tables that are in schemas on the source that dont exist in the destination? For example [DansSchema].[DansTable] on source database needs to go to [NewSchemaName].[DansTable]. DansSchema doesnt exist on the destination db.
dndaughtery
dndaughtery
SSC Eights!
SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)

Group: General Forum Members
Points: 874 Visits: 1086
I've come up with a possible work around. If you have permission to run Exe SQL Task to update the schema on the source to the dbo schema which more than likely will exist on both databases, copy the table over into the dbo schema in the destination, Update the src tables back to original schema, then update the destination to the desired schema in anothe exe sql task.
dndaughtery
dndaughtery
SSC Eights!
SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)SSC Eights! (874 reputation)

Group: General Forum Members
Points: 874 Visits: 1086
Actually went in this direction. I created the missinig schemas on my destination db, ran the obj transfer, then ran the following to move all tables into the corrrect schema


exec sp_MSforeachtable 'ALTER SCHEMA [Schema to Move To] TRANSFER ?'

Then I dropped the unneeded schemas.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search