SQL Question

C

cableone

Here is what probably is a stupid question, I do this all the time in
coldFusion, but I would like to do it all in transact-sql. Basically, I have
table A with records, I want to loop over the records in tableA and insert 1
(or a few) in tableB essentially:

begin

select top 10 * from members

INSERT INTO test

(

hello

)

VALUES

(

'a'

)

end

the top statement returns a list (the select top 10), and inserts 1 record
to "test" with "a" in the hello field. I want it to insert 10 records, and
mabe even change 'a' to values pulled from "members"

In cold fusion, I just do:

Execute "theSelectQuery"

<cfloop query='theSelectQUery">

insert ... (values from theSelectQuery)

</cfloop< (end loop)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top