Primary key
|
Unique Key
|
1- Primary
key doesn’t have null value.
2- A
table can have only one primary key.
3- By
default primary key have clustered index.
|
Unique key can hold null value but only once.
A table can have more than on unique key.
By default Unique key have non- clustered index.
|
/*Bulk update query*/ create table Table1 ( ID int identity ( 1 , 1 ), vIsbn varchar ( 20 ), dcPrice decimal ( 18 , 2 ) ) create table Table2 ( ID int identity ( 1 , 1 ), vIsbn varchar ( 20 ), dcPrice decimal ( 18 , 2 ) ) /*Here create two tables, we update Table1's dcPrice column from Table 2 Using Bulk update*/ insert into Table1 ( vIsbn , dcPrice ) values ( '9087657654312' , 0.00 ) insert into Table1 ( vIsbn , dcPrice ) values ( '9989876765454' , 0.00 ) insert into Table2 ( vIsbn , dcPrice ) values ( '9087657654312' , 10.20 ) insert into Table2 ( vIsbn , dcPrice ) values ( '9989876765454' , 20.10 ) select * from Table1 /*here bulk update Query*/ UPDATE Tbl SET dcPrice = Tbl2 . dcPrice FROM Table1 Tbl JOIN Table2 AS Tbl2 ON Tbl . vIsbn = Tbl2 . vIsbn select * from Table1 drop table Table1 dr
Comments
Post a Comment