How do I create a SQL table under a different schema?

前端 未结 6 1170
天命终不由人
天命终不由人 2020-12-23 19:59

This is from SQL Server 2008, ssms

When I create a table, it creates under dbo.

I would like to create it under a different schema, but when I use the \'New

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 20:38

    Try running CREATE TABLE [schemaname].[tableName]; GO;

    This assumes the schemaname exists in your database. Please use CREATE SCHEMA [schemaname] if you need to create a schema as well.

    EDIT: updated to note SQL Server 11.03 requiring this be the only statement in the batch.

提交回复
热议问题