Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert into DB 1

Status
Not open for further replies.

dhmfh

Programmer
Nov 28, 2005
69
GB
Hi Guys

I want to insert 10 records into a db table. Is there a better way of doing this rather than writing 10 insert statements. If so can you point me in the right direction

Kind regards
 
W/o knowing what you will insert it is hard to me to say what is better way ;-)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
will be inserting 10 records into a new table based on an Id

insert into table (id, value)
values (1,1)
insert into table (id, value)
values (1,2)
insert into table (id, value)
values (1,3)
insert into table (id, value)
values (1,4)
insert into table (id, value)
values (1,5)

and so on.

Hope that helps
 
If this is the actual replace (I doubt it)
Code:
DECLARE @i int
SET @i = 0
WHILE @i < 11
      BEGIN
         SET @i = @i +1
         INSERT INTO Table (id, value) values (1,@i)
      END

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top