Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
How to alter a schema of already created table in SQL?

I tried the below:

alter schema dbo TRANSFER [xxx].[MytableName] and got the below error msg.

Msg 15151, Level 16, State 1, Line 3
Cannot find the object 'LANGUAGE_TYPE', because it does not exist or you do not have permission.

Is there any othe way to do this? Pls help

Regards
DhivyaJ
Posted
Comments
CHill60 13-Nov-13 6:43am    
What are you actually trying to do with the table?
Dhivya.J 13-Nov-13 6:45am    
I am trying to change the schema of "dbo.MytableName" to "xxx.MytableName".

is there any schema named xxx in your sql server if not then create one
SQL
CREATE SCHEMA xxx

then try alter Your Table Like
SQL
ALTER SCHEMA NewSchema TRANSFER OldSchema.YourTable 
GO

for more detail see this ALTER SCHEMA (Transact-SQL)
 
Share this answer
 
v2
According to your comment you try to move MyTableName table from dbo to xxx...
You command try to do just the opposite.
The format of ALTER SCHEMA goes like this
SQL
ALTER SCHEMA {target-schema-name} TRANSFER {original-schema-name}.{table-name}

In you case
SQL
ALTER SCHEMA xxx TRANSFER dbo.MyTableName
 
Share this answer
 
See, for instance, this Stack Overflow question[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900