Adding rows to SQL table depending on key values from another table

I have three tables.

Table A - Vendor Contracts Table
Table B - Vendor Agreement Details
Table C - Vendor Agreement codes and descriptions

What I need to do is for every vendor in table A,  add rows to table B for each of the rows in table C.

So for instance I have Vendor 1234567890 in Table A, I want to add rows to table B for that vendor for every "Vnn" row in table C.   "Vnn" is just a serious of codes from V1 - V9.  

There are currently a total of 9 "Vnn" codes and there respective descriptions in Table C.   So in Table B I would end up with the following:

Vendor                           Code
123456789                      V01
123456789                      V02
123456789                      V09

and of course for each of the other Vendors in table A.

No need to worry to much about what other columns will be selected/added.  I just need to know what the structure/syntax would look like to do this.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert LindIT DirectorCommented:
I think this is what you are looking for.  Insert from select?

DECLARE @b TABLE ( tableAID int, details varchar(10))

DECLARE @c TABLE (tableAID INT ,details VARCHAR(10))


INSERT INTO @c (tableAID,Details) VALUES (3,'Text 3')
INSERT INTO @c (tableAID,Details) VALUES (5,'Text 5')
INSERT INTO @c (tableAID,Details) VALUES (1,'Text 1')
INSERT INTO @c (tableAID,Details) VALUES (1,'Text 11')
INSERT INTO @c (tableAID,Details) VALUES (1,'Text 111')

INSERT INTO @B (tableaid,details)
SELECT  c.tableaid,c.details FROM @c  c INNER JOIN @a a ON = c.tableaid


tableAID      details
3      Text 3
1      Text 1
1      Text 11
1      Text 111

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
66chawgerAuthor Commented:
So in the example above, you are using "tableAID" to select all the information from the various tables, then using this for the resulting insert, correct?
Robert LindIT DirectorCommented:
Yes.  In your case, you would have to match the ID's for your tables, from your example that would be the vendor column in tables a and c.
66chawgerAuthor Commented:
I was making this waaaaay to difficult.. LOL.  My mindset has been tied up so much in SP's and TSQL that I forgot to think simple!

Thanks for the example.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.