Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change DB schema from dbo to another schema?

I created a new view that have a lot of joins between multiple tables , under SQL Server 2012 Management.

The view was created under the name dbo.vw_clientsTransactions .

How can I change the DB schema from dbo.vw_clientsTransactions , to CL.vw_clientsTransactions ?

Thanks

like image 859
JAN Avatar asked Dec 25 '22 00:12

JAN


2 Answers

To change the schema of any object, use the following syntax:

alter schema [new_schema] transfer [old_schema].[object_name];

So, in your case, you'd do:

alter schema [CL] transfer [dbo].[vw_clientsTransactions];
like image 108
Ben Thul Avatar answered Jan 11 '23 20:01

Ben Thul


You have to delete this view and, on Create, specify your schema in the view name!

like image 44
rodrigogq Avatar answered Jan 11 '23 20:01

rodrigogq