Alter schema statement - Incorrect syntax near '\'.

  • I am trying to use the alter schema statement on a table with this name:

    ABC\genn.smith.itemresults

    with this statement

    ALTER SCHEMA dbo TRANSFER ABC\genn.smith.itemresults

    and I get this error:

    Incorrect syntax near '\'.

    What does that mean? How can I change the schema to dbo lif the schema is ABC\genn.smit?

    Thank you.

  • Script the table, change the schema to dbo, run the updated script, use a simple insert script to move any data from the old table to the new table, drop the old table.

  • Kbear (5/7/2013)


    I am trying to use the alter schema statement on a table with this name:

    ABC\genn.smith.itemresults

    with this statement

    ALTER SCHEMA dbo TRANSFER ABC\genn.smith.itemresults

    and I get this error:

    Incorrect syntax near '\'.

    What does that mean? How can I change the schema to dbo lif the schema is ABC\genn.smit?

    Thank you.

    I am a little confused about what is the table name and what is the schema but you need to wrap your table name in []

    I think you said the current schema is ABC\genn.smit.

    That would mean the syntax for this would be:

    ALTER SCHEMA dbo TRANSFER [ABC\genn.smith].itemresults

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Sean Lange (5/7/2013)


    Kbear (5/7/2013)


    I am trying to use the alter schema statement on a table with this name:

    ABC\genn.smith.itemresults

    with this statement

    ALTER SCHEMA dbo TRANSFER ABC\genn.smith.itemresults

    and I get this error:

    Incorrect syntax near '\'.

    What does that mean? How can I change the schema to dbo lif the schema is ABC\genn.smit?

    Thank you.

    I am a little confused about what is the table name and what is the schema but you need to wrap your table name in []

    I think you said the current schema is ABC\genn.smit.

    That would mean the syntax for this would be:

    ALTER SCHEMA dbo TRANSFER [ABC\genn.smith].itemresults

    I have not used ALTER SCHEMA like this, but after reading up on it and testing it in a sandbox database, I would agree with Sean.

  • Thank you for all the responses. I found how to change the schema name through management studio. But - When I look at the table it still says

    ABC\genn.smith.itemresults

    The name of the table is itemresults but I can't get rid of the "ABC\genn.smith." at the front of it. I also don't know why these tables are getting these names. ABC is our new domain (not really ABC, just trying to be anonymous) so users are being moved from OldDomain to ABC. Two people on the new domain suddenly are having tables they create come up with the ABC\first.last in front of the table name.

    Any advice on these two issues? Thanks again.

  • OK - changing it through management studio really didn't change it but the syntax with [ ] around the offending part of the schema name worked. Thank you.

    Still would like to know why it creates tables with the funny schema name attached.

  • Kbear (5/7/2013)


    OK - changing it through management studio really didn't change it but the syntax with [ ] around the offending part of the schema name worked. Thank you.

    Still would like to know why it creates tables with the funny schema name attached.

    Check the default schema for those users.

  • Thank you all.

Viewing 8 posts - 1 through 7 (of 7 total)

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