Robb Hill
asked on
SQL - Curser to do an insert based on a select
Its has been years since I wrote a curser and was hoping for some guidence.
Lets say I have a select statement that returns me a unique list of Customers
So here is the select
Select c.Customer
FROM CustomerTable.c
So I would need to iterate through each c.Customer
And create an insert based on the values of that row in the select.
So the insert is another table...and the 3 values in the insert are from the row im interating on.
--INSERT INTO [dbo].[tClientXContact]
--([nIDClient]
--,[c.Customer]
--,[lNotify])
--SELECT distinct c.nid, c.Customer,1
Lets say I have a select statement that returns me a unique list of Customers
So here is the select
Select c.Customer
FROM CustomerTable.c
So I would need to iterate through each c.Customer
And create an insert based on the values of that row in the select.
So the insert is another table...and the 3 values in the insert are from the row im interating on.
--INSERT INTO [dbo].[tClientXContact]
--([nIDClient]
--,[c.Customer]
--,[lNotify])
--SELECT distinct c.nid, c.Customer,1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER