Tutorial based on how to Use Microsoft SQL Server and Create Database and Tables Quires Step by Step with Screenshots
Starting SQL Server
1. Launch
SQL Server Management Studio (Start-> All Programs->Microsoft SQL Server
2005 -> SQL Server Management Studio)
2. Connect
to the SQL server on the local machine.
3. Under
the Object Explorer pane, expand the SQL Server database folder if it is not
already expanded.
4. You
will see something similar to the figure below:
Attaching
a Database in SQL Server 2005
1. Right
click on Databases
2. Choose
New Database…
3. The
following screen is shown. Enter YourName
(LabCS341) as the name of the database.
4. Click
on OK.
5.
A new database (YourName) will appear under Databases on the left hand side. In
this example, LabCS341 is shown as the last database in the Databases list.
Creating
a table in the database
1.
Select database LabCS341 under the Object Explorer pane.
2. Right
click on Databases LabCS341
3. Choose
New Query…
4.
Type the following command:
CREATE TABLE
Employee(employee_id int NOT NULL,last_name nvarchar(20)NOT NULL,first_name
nvarchar(20) NOT NULL,middle_name nvarchar(20) NULL,birth_date datetime NULL);
5.
Execute the command by pressing the
“Execute” button.
6.
It will give you a message
“Command(s) completed successfully”.
Insert values in the Employee table
7.
Select database LabCS341 under the Object Explorer pane.
8.
Select the New Query option from the
toolbar. A tab will be created for you to enter your query as shown below.
9.
Insert your first column in the
Employee table. Type the following command:
INSERT INTO
Employee (employee_id, last_name, first_name, middle_name, birth_date)
VALUES ('12',
'Smith', 'Mary', NULL, '02/02/1980')
10.Execute the
command by pressing the “Execute” button.
11.It will give you
a message “(1 row(s) affected)”. You
have successfully inserted first row.
12.Likewise, insert
4 more rows in your Employee table.
0 comments:
Post a Comment