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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Insertion on a loop..

Author  Topic 

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2005-02-09 : 22:19:25
I had this code on my VB...

SQL = "SELECT cbBranchName FROM tblBranch"
while not rs.EOF
'SQL INSERTION IS HERE....
rs.MoveNext
wend

Now I want to write this one on SQL, let say as of now there are 3 records on tblBranch. Now I want to write the 3 records of the field cbBranchName on the table tblStocksLocal.

How?



Want Philippines to become 1st World COuntry? Go for World War 3...

nr
SQLTeam MVY

12543 Posts

Posted - 2005-02-09 : 23:02:09
insert tblStocksLocal (cbBranchName) select cbBranchName from tblBranch

but using the branchname is probably not a good idea unless these never change.

==========================================
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
   

- Advertisement -