Link to home
Start Free TrialLog in
Avatar of Sam OZ
Sam OZFlag for Australia

asked on

Table creation in non dbo schema

Hi,
   I work with Sql server 2016 . While creating a table it is getting created in the DBO schama and I have no option to change . How can I create a table in a different schema?
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or while creating table itself, which is I guess what you are asking for...

create table [schema_name].[table_name]
(
  -- column definition goes here...
)

Open in new window

When creating an object in SQL Server, the object will be created in the default user schema if no explicit schema has been provided.
To create an object in a different database schema you'll need to explicitly say the schema name, as provided above by Nitin. Mind that the user need to have permissions to create objects in the desired schema.
You also have to create the schema first.