Insert Constructors in SQL SERVER 2005 and 2008
Dear
Developer,
Insert
Constructors in SQL SERVER 2005 and 2008, This is new feature in 2005 and 2008.
Which allow you pass multiple value statement into single insert
Statement.
SQL :-
SET IDENTITY_INSERT
[dbo].[mastAssociatedWith] ON
INSERT INTO [dbo].[mastAssociatedWith] (ID,[AssociatedWith]) VALUES
(12,'Albert Rajan'),
(15 ,'Amol Koparde'),
(1 ,'Cmk'),
(10 ,'Diwali'),
(4 ,'For'),
(14 ,'K. P. Rajeev'),
(9 ,'Mer'),
(5 ,'Obom'),
(7 ,'Per'),
(11 ,'Rajesh Sharma'),
(3 ,'Rsk'),
(6 ,'Sfk'),
(13 ,'Sushil Kasar'),
(2 ,'Vsk')
SET IDENTITY_INSERT [dbo].[mastAssociatedWith] OFF
INSERT INTO [dbo].[mastAssociatedWith] (ID,[AssociatedWith]) VALUES
(12,'Albert Rajan'),
(15 ,'Amol Koparde'),
(1 ,'Cmk'),
(10 ,'Diwali'),
(4 ,'For'),
(14 ,'K. P. Rajeev'),
(9 ,'Mer'),
(5 ,'Obom'),
(7 ,'Per'),
(11 ,'Rajesh Sharma'),
(3 ,'Rsk'),
(6 ,'Sfk'),
(13 ,'Sushil Kasar'),
(2 ,'Vsk')
SET IDENTITY_INSERT [dbo].[mastAssociatedWith] OFF
It has help me to perform
task for import data from client database to my development
database.
I was given task to
import client data into development database.Data was given in text file. I had
multiple choose to import data into SQL SERVER Table. Some of them. I regular
use.
1.DTS
2.Add Data
manually
3.Use Insert statement
.
For such a
small set of data using DTS is not worth. Adding Data Manually for me.
NAAAAAAAAAAAAAA!. I am to lazy to perform such task.
last option is have
insert Statement. Conventional way of insert statement will take more time and
repeating insert statement. Hoooooooooooo! lot of hand work to copy and
paste.
I choose insert with
Constructors . Single Insert Statement and multiple Value Parameters with Comma
separated.
Some of the points I
found why and why not to use Insert with Constructors
Pro : No Multiple Round
Trip.
No Need to have
SQL Transaction {If You are running from front End}
No repeating of
Field name for Each Value Statement
Cons. If error is
generated in sql . Finding which data row has generated error will be
difficult
Switin
Comments
Post a Comment