Thursday, January 20, 2011

Create a database schema in SQL Server

Source: http://msdn.microsoft.com/en-us/library/dd207005.aspx

In recent versions of sql server specifically 2005 and 2008, the database called Adventure works seems to be a good example with lots of tables to play with.

When I tried to open the database, the tables have prefix or have namespace before it.
Example: HumanResources.EmployeeAddress

In the previous example called northwind and pubs,table names were just one word.

So, to create a schema, here's how to do it:
1:  create schema <schema_name>  
2:  go  
3:  alter schema <schema_name>  
4:  transfer <dbo.yourtable>   
5:  go  
6:  -- show table  
7:  select * from schema_name.tablename  

0 comments:

Post a Comment