0% found this document useful (0 votes)
80 views8 pages

Idb Lab 2

This document provides instructions for connecting to and interacting with Microsoft SQL Server. It describes how to check that the SQL Server service is running, launch the SQL Server Management Studio application, and connect to a server using Windows authentication. It also explains how to expand the database section in Object Explorer to see existing databases, create a new database, and rename it. Additional topics covered include deleting a database, creating, saving, and deleting tables, adding and setting data types for fields, adding and deleting data using the GUI, and introductions to SQL, DDL, DML, and DQL.

Uploaded by

Zahoor ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views8 pages

Idb Lab 2

This document provides instructions for connecting to and interacting with Microsoft SQL Server. It describes how to check that the SQL Server service is running, launch the SQL Server Management Studio application, and connect to a server using Windows authentication. It also explains how to expand the database section in Object Explorer to see existing databases, create a new database, and rename it. Additional topics covered include deleting a database, creating, saving, and deleting tables, adding and setting data types for fields, adding and deleting data using the GUI, and introductions to SQL, DDL, DML, and DQL.

Uploaded by

Zahoor ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

LAB MANUAL May 22, 2015

Lab#2
Introduction to Microsoft SQL Server

Because Microsoft SQL Server works as a service to the operating system, in order to use
it, you must make sure its service has started. Sometimes you will have to start the service
and sometimes you will have to stop it. To check it, you can open the Control Panel and
the Administrative Tools. In the Administrative Tools window, open the Services.
Sometimes you will launch Microsoft SQL Server and try to connect but you may receive
an error message stating that the connection could not be established even though you
know that the username is correct. If that happens, check the service and start it.
a Interaction with login screen of MS SQL Server, putting your credentials to login and logging
in MS SQL Server

Interaction with login screen of MS SQL Server, putting your


credential to login and logging in MS SQL Server

In order to do anything significant in Microsoft SQL Server, you will have to establish a
connection to it. If you start Microsoft SQL Server Management Studio from the Start
button, the Connect to Server dialog box would come up:

The easiest way to connect is


to select Windows
Authentication in the
Authentication combo box.
The User Name combo box
should have the name of the
computer, followed by a back
slash, and followed by the
user name of the account that
is currently logged in. You

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015
don't have to enter a password (this is because you are using Windows
Authentication and because you are logged in already):

 Interacting with Object Explorer of MS SQL Server Management Studio

Interacting with object Explorer of MS SQL Server Management


Studio

There are some object Explorer of MS SQL Server Management Studio .in these explorer
database, security and server object and some other element are include.

Expanding Database section of Object Explorer and revealing existing


database

If we expand the database section there are some option which is related to the
database section. Those database are present in this section which we maked and
we can open.

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015

Creating new Database using Objective Explorer and renaming

First right click on the database option .after that click on the new database .after
that the new window will open on that window you will give name of your
database .

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015
Deleting existing database

After making the database and providing the name of the database if you want to delete the
current database , so expend the database option and right click on your database
name .after that click on the delete option your database will delete.

Creating new table, saving table and deleting table

After making the database next step is making of table. Expend your database and right
click on the table option and click on the create new
table. Your table will create.
Next is saving of table you must fill the field of the
table, after that you will able to save and delete the
table. Right Click top on the field and click on save.

Next step is deleting the table, first right click on


the table option and click on refresh. After that
expend the tables and right click on that table which
you want to delete and click on delete.

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015

Adding fields to new table and setting data type of fields

After making the table next steps is making the field click on the fields and give the name
and select the data types.

 Adding data in tables and deleting data in tables using GUI

Adding data in table and deleting data in tables using GUI

Right click on that table which you want to add some data and select the edit top
200 row after that you will able to add data in table.

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015

Introduction to SQL

 SQL is a standard language for accessing and manipulating databases. SQL can
execute queries against a database
 SQL can retrieve data from a database
 SQL can insert records in a database
 SQL can update records in a database
 SQL can delete records from a database
 SQL can create new databases
 Introduction to Data Definition Language (DDL), Data Manipulation Language (DML) and Data
Query Language (DQL)

Introduction to Data Definition language,DML and DQL

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015
DML is abbreviation of Data Manipulation Language. It is used to retrieve, store,
modify, delete, insert and update data in database.
Examples: SELECT, UPDATE, delete and INSERT statements

DDL
DDL is abbreviation of Data Definition Language. It is used to create and modify the
structure of database objects in database.
Examples: CREATE, ALTER, and DROP statements

 DQL (Data Query Language) refers to the SELECT, SHOW and HELP statements
(queries)
SELECT is the main DQL instruction. It retrieves data you need. SHOW retrieves infos
about the metadata. HELP... is for people who need help.

 The Create Database Command: Used to create New Database


o Example: CREATE DATABASE University DB;
And
 The Create Table Command:
o Example: CREATE TABLE student(stuID int PRIMARY KEY, firstName varchar(50));

 Inserting Data into Tables


o Exmple: INSERT INTO student (stuID, firstName) VALUES(1, ‘Hamza’);

ZAHOOR AHMED CMSID 24911


LAB MANUAL May 22, 2015
 Viewing data in the tables
o To view all fields and their data
 Example: SELECT * FROM students

o To view all fields and their data


 Example: SELECT stuID FROM tableName;

o Filed Aliases/ Column Aliases


o Syntax: SELECT <column name> AS <alias> FROM tablename;
o Example: SELECT stuID AS ‘IDs of Students’ FROM students;
o

ZAHOOR AHMED CMSID 24911

You might also like