TSQL1.htm
Objectives:
  • Creating A DB using SQL-SERVER 2005 Express
  • Creating EMP and DEPT table, using GUI Tools
Step: 1 Start SQL Server

Connect, and appear at Object Explorer screen

Step : 2

Step 2 Creating New DB

Click on OK

Step ; 3 Create New Table

Add columns and save as DEPT

and a view generated script to clip board

USE [empdb1]
GO
/****** Object: Table [dbo].[DEPT] Script Date: 11/09/2003 12:21:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[DEPT](
[DEPTNO] [nchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DNAME] [varchar](14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LOC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED
(
[DEPTNO] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

 

Open the table and fill out the cells

 

Step : creating EMP table


Set a primary Key to EMPNO and Foreign key To deptno, using Relationship menu

Adding relationship / foreign key

Note the relationship screen shot