SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Alter schema statement - Incorrect syntax near '\'.


Alter schema statement - Incorrect syntax near '\'.

Author
Message
Kbear
Kbear
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 741
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.
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39844 Visits: 38563
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.

Cool
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)
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26317 Visits: 17553
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.

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)
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39844 Visits: 38563
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.

Cool
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)
Kbear
Kbear
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 741
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.
Kbear
Kbear
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 741
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.
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39844 Visits: 38563
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.

Cool
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)
Kbear
Kbear
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 741
Thank you all.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search