I'd like to add new schema (like dbo but with different name, ex. Fruit) to database. I'm using database project in Visual Studio 2013. I have an existing database project with tables, schemas, stored procedures, pre and post deployment scripts, etc. Database project is version controlled. I'd like generating publish scripts to work nicely as it did before I added a new schema.
Creating Fruit.schema.sql in SchemaObjects/Database Level Objects/Security/Schemas with content
CREATE SCHEMA [Fruit]
will create schema but won't add Fruit schema folder sub tree in Schema Objects/Schemas folder like dbo schema has. Should I create that subtree manually? I suspect there is smarter way to achive this.
To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema. ALTER SCHEMA uses a schema level lock.
In Visual Studio 2017, I can add item => search for schema, and that creates a sql file that includes the line: create schema [fruit]
.
Then, I can reference that schema when creating other database objects.
Yes, create the folder manually. There's no smarter way to do this :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With