Wednesday 31 May 2017

Difference between PRIMARY KEY and UNIQUE KEY

Below are the difference between the Primary and Unique Key

We can create multiple unique keys in the table but only one primary key

See the example
Here I am creating a table which has only one primary key
Create table Emp
(
ID int primary key,
Name varchar(50),
SSN int,
Mobile_Number int
)
Table creates successfully.
 
Now I am trying to create one more primary key on SSN. See below
Getting below error
 
It means we can’t create multiple Primary key in a table.
Now I am creating the Unique key in the table.
 
Two unique key I created. It means we can create n number of unique key in a table.

Unique Keys can have a null value but the primary keys can’t have nulls

See the below example
Primary key can’t have a null value.
 
Now again I want to insert a records with ID=1.
Throwing below error
 
When we trying to insert NULL value in primary key getting below error.
  

In unique key column one null will accept see below

 

A unique column has only one null value. We can’t insert the multiple null values in the table.  
 

When we trying to insert duplicate value in unique key column vale getting below error
 

By default Indexes

Primary key create clustered index by default. But Unique creates a non-clustered index.
See the example
With the help of below SQL script we will get the table information
SP_HELP Emp

 
 


Tuesday 30 May 2017

Writing the Technical document for the SSIS package

When we writing the technical document we need to cover below points.
1.       Purpose of the package
2.       Job frequency details
3.       Email notification details
4.       Audit process on package start
5.       Extraction process
6.       Source
7.       Transformation and business logic
8.       Destination
9.       Audit information on end of the package
10.   Dependencies
11.   Troubleshooting
12.   Dynamic package configuration
13.   Logging and event handling
14.   Important Links

Popular Posts