0

I want to create Employee2 table in adventureworks database. However when I create a table using graphic interface and save it then it has the prefix dbo and saved as dbo.Employee2.

I wish to save the table in HumanResources schema as it will be saved as HumanResources.Employee2. How to do this?!!

Ameya Deshpande
  • 3,580
  • 4
  • 30
  • 46
SimpleGuy
  • 1
  • 1
  • You need to use **select * into HumanResources.Employee2 from dbo.Employee** – knkarthick24 Jan 06 '15 at 07:24
  • Here is the answer - you need to open table properties http://stackoverflow.com/questions/1489872/how-do-i-create-a-sql-table-under-a-different-schema – fly_ua Jan 06 '15 at 07:26
  • If you press F4 (options window) in SSMS you are able to change the schema in the options window as per @fly_ua 's link – Steve Ford Jan 06 '15 at 09:50

2 Answers2

0
IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'HumanResources ')) 
BEGIN
    EXEC ('CREATE SCHEMA [HumanResources] AUTHORIZATION [dbo]')
END

ALTER SCHEMA HumanResources
    TRANSFER dbo.Employee2 
mohan111
  • 8,633
  • 4
  • 28
  • 55
0

Try to understand you want to create a Table Employee2 in a defined schema HumanResources of adventureworks sample Db.

So going with GUI Go to New Table then define your Employee2 columns and datatypes etc then on Properties windows at right side of screen choose your schema HumanResources and save it. Thats it.

TraDev
  • 3
  • 3