Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Populate a table


Message #1 by "Bob Burkett" <bobb0198@h...> on Sun, 8 Jul 2001 07:23:17 -0500
Yes ... looks great.  I appreciate the help.

Bobb


----- Original Message -----
From: <rnedel@b...>
To: "sql language" <sql_language@p...>
Sent: Sunday, July 08, 2001 9:24 PM
Subject: [sql_language] Re: Populate a table


> Bobb:
>
> Other than slightly altered field names, this should work for you.
Cheers.
>
> - Roger Nedel
>
>   Nedel Software Solutions
>   Salt Lake City, UT
>   rnedel@b...
>
>   ------------------------
>
>   DECLARE @i int
>   SET @i = 1
>
>   WHILE @i <= 10000
>   BEGIN
>
>     INSERT INTO tblRedHat
>     (
>       vchName,
>       vchCity
>     )
>     VALUES
>     (
>       'Name' + CONVERT(varchar, @i),
>       'City' + CONVERT(varchar, @i)
>     )
>
>     SET @i = @i + 1
>
>   END
>
>   ------------------------
>
> > Suppose I have an existing table called Redhat with a small number of 
> > records in it.  Say the fields are
> > 
> > EmployeeID     (auto numbered)
> > Name varChar(20)
> > City varChar(20)
> >
> > ... and I just want to stoke the table up with data ... say 10,000 
> > records.  Maybe something like Name1, Name2 ... Name10000
> > City1, City2 ... City10000
> > etc
> >
> > Seems like something like the following might do?
> >
> > for item_num =3D 1 to 10000 step 1
> >     INSERT INTO Redhat (Name,City)
> >         Values('Henry' & str(item_num),'City' & str(item_num))
> > next
> >
> > I just want to take a name and a city and concatenate the index loop 
> > number on to the end of each field for each additional record.
> >
> > I would appreciate any help,
> >
> > bobb


  Return to Index