Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 please help me

Author  Topic 

born2acheive
Yak Posting Veteran

65 Posts

Posted - 2006-10-09 : 06:25:26
hi,

i want to insert multiple record at a time,
for example:

in MYSQL we use the following:

insert into emp values('karthik',23),('jimmy',28),('billy',46)

like wise i want to insert multiple records at a time in sql server,so please give me query to do this ,pleaseeeeeeeeeeeeeeee

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-09 : 06:34:41
insert into emp
select 'karthik',23 union all
SELECT 'jimmy',28 union all
SELECT 'billy',46

Peter Larsson
Helsingborg, Sweden

EDIT: Added code in red.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-10-09 : 06:44:35
insert into emp
select 'karthik',23 union all
select 'jimmy',28 union all
select 'billy',46

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-09 : 06:48:01
OMG. How could I forget SELECT?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-09 : 09:15:37
quote:
Originally posted by born2acheive

hi,

i want to insert multiple record at a time,
for example:

in MYSQL we use the following:

insert into emp values('karthik',23),('jimmy',28),('billy',46)

like wise i want to insert multiple records at a time in sql server,so please give me query to do this ,pleaseeeeeeeeeeeeeeee




Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-09 : 09:44:10
Well that is SQL...just not ANSI

Evry platform has "features" though

SELECT @OrderId = OrderId FROM Orders

Boy did I have a hard time with that



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-09 : 10:41:14
>>SELECT @OrderId = OrderId FROM Orders

I always expect it to return error "Query returns more than one value" if there are more than one value

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-09 : 10:52:22
quote:
Originally posted by madhivanan

>>SELECT @OrderId = OrderId FROM Orders

I always expect it to return error "Query returns more than one value" if there are more than one value

Madhivanan

Failing to plan is Planning to fail



Well then you must have a DB2 background

-802



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-09 : 11:51:46
>>Well then you must have a DB2 background

No

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -