kinkajou
kinkajou

Reputation: 3728

Creating view in SQL Server 2008 using SSMS

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

Answers (1)

Martin Smith
Martin Smith

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.

enter image description here

Upvotes: 5

Related Questions