Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2008
    Posts
    55

    Unanswered: Change a Table Schema to dbo

    Hello Everyone,

    I have created a table on SQL Server from SAS. The table gets created fine. However, the table schema has my user ID in it (AD-ENT\myuserid.Table1). How can I change the schema to dbo.(dbo.Table1)? It's fine if I have to make this change in SQL Server Management Studio.

    Thank you in advance for any input!

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    There are many ways to accomplish this.

    First and foremost, I would suggest that you create the table using explicit dbo.table naming so that it simply gets created in the schema where you want it.

    Depending on what version of SQL Server you are using, another option might be ALTER SCHEMA.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Aug 2008
    Posts
    55
    Thank you Pat!

    I tried running this code:
    ALTER SCHEMA dbo TRANSFER AD-ENT\myuserid and received an error "Incorrect syntax near '-'

    any suggestions?
    Thanks!
    Last edited by KevinYC; 12-09-13 at 17:35.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Both the dash and the backslash are "special" characters to SQL Server, so they need to be quoted. I'd use:
    Code:
    ALTER SCHEMA dbo TRANSFER [AD-ENT\myuserid].[My-Object]
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Aug 2008
    Posts
    55
    Thank you, Pat. That worked beautifully!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •