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


how to change new schema name from existing schema - Table


how to change new schema name from existing schema - Table

Author
Message
SQL Galaxy
SQL Galaxy
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7081 Visits: 3501
Hi,

I want change schema name on Table.

hwdata.DesktopSoft_Master

to change

dbo.DesktopSoft_Master

I tried as below

ALTER SCHEMA HWData TRANSFER dbo.DesktopSoft_Master;

Error-
Msg 15530, Level 16, State 1, Line 1
The object with name "DesktopSoft_Master" already exists.

Can you give me script for change new schema Object.
Thanks
Lowell
Lowell
SSC Guru
SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)

Group: General Forum Members
Points: 74549 Visits: 40983
that error says the table already exists in the hwdata schema.
do a quick
select * from hwdata.DesktopSoft_Master
select * from dbo.DesktopSoft_Master

decide which one to keep (say dbo was the "good one"
then drop table hwdata.DesktopSoft_Master
and try to transfer again.

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17486 Visits: 7423
You appear to have transposed the schemas

The correct syntax is

ALTER SCHEMA the destination schema TRASFER Object::current schema.TableName;



so, using your case:
ALTER SCHEMA dbo TRANSFER HWData.DesktopSoft_Master;



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
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