2

I have create view using SSMS but I don't find option to change schema. How do I change schema in this case?

7
  • You want to change the view? Rightclick, Design (or edit) Commented Jan 21, 2012 at 11:53
  • @Matten Can't we choose that while creating it and I don't find it in design too Commented Jan 21, 2012 at 11:54
  • @Kitex... maybe just not enough coffee, but I don't understand your question :-) In SSMS, you can create a view graphically by modelling the required tables, columns and linking them to each other (instead of writing the necessary sql code). So what is you problem? Commented Jan 21, 2012 at 11:57
  • 1
    @Kitex - Simplest soulution is not to bother with the view designer. It doesn't support constructs like row_number, and mangles your code formatting. With intellisense in the script environment now can think of no good reason for wanting to use it. Commented Jan 21, 2012 at 12:51
  • 1
    Totally agree with @Martin. There are several other bugs with the view designer. "Easy" is not the same as "better" - especially when it changes the intended logic of your query. Even worse if you don't catch it. Commented Jan 21, 2012 at 17:01

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.