Solved

Loop through SQL table.

Posted on 2007-04-10
1
2,966 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now