Solved

Loop through SQL table.

Posted on 2007-04-10
1
2,971 Views
Last Modified: 2008-04-16
Hi Guys
I think what I am asking is simple.
But I can not work it out.

I have a Microsoft SQL table.
It is one column. Example below.

Product
-------------
Microsoft XP.
Windows 2003
Micrososoft SQL 2003.

I need to pick each Product and insert into another table.

An example of the insert statement : Insert into Accepted_ Products(Client_Id,ContactNumber,Product)
                                                            Values ('022222222',2,'Microsoft XP')

I need to loop through Product table replacing Product with next item.

Any help highly appreciated




0
Comment
Question by:Shezad Ahmed
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 18884728
something like this:
insert into accepted_products (Client_Id,ContactNumber,Product)
select ('022222222',2, product from yourtable
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question