CRUD Operations In SQL Server 2008

Here are the Steps:

Step 1: Open your SQL Server 2008 and connect it by using suitable method that you had chosen at the time of installation that is “Window Authentication” or “Mixed Mode”.


After connecting, you will see something like the following image, where there are lots of options available in the object explorer [left side]. Click on New Query.


Step 2:
Create Database.

Create database student

To run this Query just select the whole Query and Press F5. You will see under the database a new Database is generated with the name of student. If you can’t see your database, then just press the refresh button inside the object explorer.


create database

Step 3: Create Table inside the Student Database.

Create Table

  1. use student  
  3. create table tbl_student1   
  4. (  
  6. name varchar(50) NULL,  
  7. city varchar(50) NULL  
  8. )  
Run this query by pressing F5 and you will see in object explorer under Student Database, Table dbo.tbl_student1 name table gets created. You can check out by right clicking on that table, then Design, it will show you the design view of the table.


table design


Step 4: Now we will insert some data into out table tbl_student.

Insert Query

insert into tbl_student1(name,city)values('Nilesh','Rajkot'),('Purnima','Pune'),('Rinku','Delhi')


Query output

Step 5: Now we will write update query, suppose by chance if you entered a wrong data into the table, at that time you can’t delete the data as it will delete the relevant field and it will affect in other table too if the table is in relation with other. We will update the data of id = 2.

Update Query
  1. update tbl_student1  
  2. set   
  3. name='Rohit',  
  4. city='Shimla'  
  5. where id =2  


Step 6: Delete the Data from the table.

Delete the Data
We will delete the data of id=5.

delete from tbl_student1
where id=5



You can use drop for dropping your whole table. There are other queries too that I’ll cover up in the other sections of SQL.


Up Next