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
 INSERTING MULTIPLE ROWS IN A TABLE

Author  Topic 

vndnsingh2007
Starting Member

2 Posts

Posted - 2007-06-20 : 14:34:26
Hi,

Is it possible to insert multiple rows in a table using one INSERT statment. If yes, how can I do that ? I tried doing this using the substitution method.

Using Substitution Method - This is how,I proceeded.

INSERT INTO EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
SELECT ‘&EMPN’, ‘&ENAM’, ‘&JO’, ‘&MG’, ‘&HI’, ‘&SA’, ‘&COMM’, ‘&DEPTN’ UNION ALL
SELECT ‘&EMPN’, ‘&ENAM’, ‘&JO’, ‘&MG’, ‘&HI’, ‘&SA’, ‘&COMM’, ‘&DEPTN’

Let me know if this is correct.

Thanks,
Vandana

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-06-20 : 14:37:10
Yes.
It must have been faster to try for yourself?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

mageshks
Yak Posting Veteran

59 Posts

Posted - 2007-06-21 : 06:16:01
Why dont you try While statement..



Declare @i as int
Set @i=0
While (@i<100)
begin
--Insert statement
set @i=@i+1
end
Go to Top of Page
   

- Advertisement -