Menu

Friday, 10 January 2014

Difference between Delete & Truncate



Differentiate between DELETE and TRUNCATE

Sr. No
Truncate
Delete
1
It cannot be rolled back
It can be
2
Truncate keeps the lock on table
Delete keeps the lock on each row.
3
Truncate resets the counter of the Identity column
It doesn’t do so
4
Trigger is not fired in Truncate
Trigger happens in table.


Tuesday, 7 January 2014

Join Clause



Join means combining two or more tables in a database.

Emp_id
Emp_name
1
Suryagroops
2
Suresh
3
Mayank dixit
4
Suryagroops
5
Ramesh
6
Ramesh
7
Shalini
8
Sushil
                                                                  
                                                                     tbl_emp

Cust_id
Cust_Salary
7
3500
8
2500
9
4566
                                                                   
                                                                      tbl_cust

SELECT        Cust_id, Cust_Salary, Emp_Name 
FROM tbl_cust, tbl_emp
WHERE tbl_cust.Cust_id = tbl_emp.Emp_id

Or

SELECT        tbl_cust.Cust_ID, tbl_cust.Cust_Name, tbl_emp.emp_name
FROM            tbl_cust INNER JOIN
                         tbl_emp ON tbl_cust.Cust_ID = tbl_emp.emp_id

Result-
Cust_id
Emp_Name
Cust_Salary
7
Shalini
3500
8
Sushil
2500

Monday, 6 January 2014

TOP Clause


Emp_id
Emp_name
1
Suryagroops
2
Suresh
3
Mayank dixit
4
Suryagroops
5
Ramesh
6
Ramesh
7
Shalini
8
Sushil


                                                                 tbl_emp
TOP Clause

SELECT TOP (3) Emp_Name FROM tbl_emp

Result-
Emp_id
Emp_name
1
Suryagroops
2
Suresh
3
Mayank dixit