CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • ALTER SCHEMA to dbo

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    56
  • Date Created
    Wednesday, November 24, 2010
  • This Article Has been Viewed
    1849 times
  • Short Desc
    When you create a table in another SQL Server Mangement Studio the SCHEMA name may differ from your current name.
  • Details
    When you create a table in another SQL Server Mangement Studio, and then import that table into your current running SQL Server Management Studio, you will notice that the name of the SCHEMA is not the same as your others (Default SCHEMA Name: dbo)

    If you choose not to correct this issue, then you will have to provide the SCHEMA name with your table name in your SQL Statements.

    Example
    <%
    sql.commandtext="select column from myschema.tablename"
    %>
  • Recreate Issue
    Importing databases or tables into other SQL Server Management Studios will cause the SCHEMA names to differ from one another.
  • Resolve Issue
    To correct this issue within SQL Server Management Studio.
    Perform the following action.

    Right click on the Database name
    Choose New Query
    Paste this into the Query editor.

    ALTER SCHEMA dbo TRANSFER otherschema.yourtablename

    If you have multiple tables that need to have their SCHEMA names changed, simply just copy this code out as many times as needed, and change the .yourtablename for each one and run them all together.
    To view the ending results, you will need to colapse the database tree in the Object Explorer and then Right click on your database and choose Refresh.
    You will then see the live version of your database with the changed SCHEMA names.