Create Schema into a different database

  • Is there a way to create schemas from database X into database Y? I want to copy all of them from X to Y using T-SQL within an SP (no back and forth between the application and SQL). (SSIS is not available in the edition I'm currently working on)

    Database X & Y names are dynamic therefore scripts must often be done dynamically when having cross databases tasks to do.

    Unfortunately it's not possible to do something like:

    Using DatabaseNameX connection

    CREATE SCHEMA DatabaseNameY.NewSchemaName AUTHORIZATION abc

    Through dynamic SQL, use database and go cannot be used to switch database and create the schema on the databaseY inside the dymamic sql context (or did I missed something?)

    Thank you

  • Its difficult. :w00t:

  • :hehe: thank you for your support! I've already notice it was hard hence the question 😀

  • schema creation is not a very regular activity that need to be created dynamically or using procedures. Its administrative work and usually done whenever required and which is very rare. I wonder why you have such kind of requirement.:-)

  • Administrative operations need to be done automatically and autonomously.

    Once deployed, there will be no way to go back and check.

Viewing 5 posts - 1 through 4 (of 4 total)

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