Insert multiple records to a table using single query in sqlserver

13 Aug

create table tblEmp (eid int, ename varchar(20), estatus bit)


insert into tblEmp select 1,’emp1′,’True’

union all select 2,’emp2′,’True’

union all select 3,’emp3′,’True’


insert into tblEmp values (1,’emp1′,’True’),(2,’emp2′,’True’),(3,’emp3′,’True’)


If table not exist in database then:

select * into tblEmp from (select 1 eid,’emp1′ ename,’True’ estatus) tbltemp

Leave a comment

Posted by on August 13, 2012 in .NET, SQL SERVER


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: