Reputation: 3728
I have create view using SSMS but I don't find option to change schema. How do I change schema in this case?
Upvotes: 2
Views: 3590
Reputation: 452988
You can change the view to a new schema via TSQL ALTER SCHEMA ... TRANSFER ...
. Full example below
CREATE VIEW dbo.Foo
AS
SELECT 1 AS X
GO
CREATE SCHEMA bar
GO
ALTER SCHEMA bar TRANSFER dbo.Foo;
SELECT *
FROM bar.Foo
In general just create it in the correct schema with CREATE VIEW bar.xyz
.
As far as the SSMS View designer goes the dialogue that comes up on Ctrl + S just accepts a name and has nowhere to input a schema but before saving the view you can bring up the properties window (with F4) and define the schema there.
Upvotes: 5