Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Alter schema statement - Incorrect syntax near '\'. Expand / Collapse
Author
Message
Posted Tuesday, May 7, 2013 3:12 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 10, 2013 3:12 PM
Points: 397, Visits: 739
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.
Post #1450339
Posted Tuesday, May 7, 2013 3:19 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:02 PM
Points: 20,862, Visits: 32,893
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.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1450342
Posted Tuesday, May 7, 2013 3:21 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, December 19, 2014 2:05 PM
Points: 13,327, Visits: 12,820
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1450344
Posted Tuesday, May 7, 2013 3:25 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:02 PM
Points: 20,862, Visits: 32,893
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.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1450346
Posted Tuesday, May 7, 2013 4:16 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 10, 2013 3:12 PM
Points: 397, Visits: 739
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.

Post #1450356
Posted Tuesday, May 7, 2013 4:22 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 10, 2013 3:12 PM
Points: 397, Visits: 739
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.

Post #1450357
Posted Tuesday, May 7, 2013 6:31 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:02 PM
Points: 20,862, Visits: 32,893
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.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1450380
Posted Wednesday, May 8, 2013 11:42 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 10, 2013 3:12 PM
Points: 397, Visits: 739
Thank you all.
Post #1450717
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse