15 February 2014

CRUD Operation in SQL Server

If you are new in Sql Server and you want to be a Expert in Sql than follow my blog step by step.

I will explain the CRUD operation in this tutorial as CRUD operation known for.

Create = INSERT or Create New Table
Read = SELECT
Update = UPDATE
Delete = DELETE

Query for creating a table
"Create table table_Name(column1 datatype,column2 datatype2.......)"

Example1. Create table tbl_Student(StudentId int,StudentName varchar(30))

tbl_Student
StudentIdStudentName
Query for insert Data into table
"Insert into (table_name) values(value1,value2,value3......)"
Insert into tbl_Student values(1,'Manish');
Insert into tbl_Student values(2,'Rahul');

tbl_Student
StudentIdStudentName
Stack region5 Digits
Heap region4 Digits
Query for (Select or Read) Data into table
"select * from table_Name "
select * from tbl_Student 

tbl_Student
StudentIdStudentName
1Manish
2Rahul
Query for Update Data of table

UPDATE table_Name SET column1=value1,column2=value2,... WHERE some_column=some_value;
UPDATE tbl_Student SET StudentName='Gyan' WHERE StudentName='Manish';

tbl_Student
StudentIdStudentName
1Gyan
2Rahul
Query for Delete Data from table
" Delete from table_Name"
delete from tbl_student where StudentId=1;

tbl_Student
StudentIdStudentName
2Rahul
or
delete from tbl_student
StudentIdStudentName

No comments:

Post a Comment