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

  • 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.

  • 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.

  • 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.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply