December 17, 2008 at 2:54 pm
I'm new in T-SQL,
can someone help me with big problem for me, but redicilus problem for a T-SQL programmer?
I have 3 tables:
Table1, Table2, Table3
Table1 is having 100 records (fields are: ID_T1 (auto), Col1, Col2,...)
Table2 is having 20 records (fields are: ID_T2 (auto), Col1, Col2,...)
Table3 is empty (Fields are: ID_T3 (auto), ID_T1, Col1, Col2,...)
What I want to do is with T-SQL loop to insert in Table3 for each row in Table1 all records from Table2.
I want to build a test data for testing relational tables.
Thnx, Davor
December 17, 2008 at 3:17 pm
Davor Geci (12/17/2008)
I'm new in T-SQL,can someone help me with big problem for me, but redicilus problem for a T-SQL programmer?
I have 3 tables:
Table1, Table2, Table3
Table1 is having 100 records (fields are: ID_T1 (auto), Col1, Col2,...)
Table2 is having 20 records (fields are: ID_T2 (auto), Col1, Col2,...)
Table3 is empty (Fields are: ID_T3 (auto), ID_T1, Col1, Col2,...)
What I want to do is with T-SQL loop to insert in Table3 for each row in Table1 all records from Table2.
I want to build a test data for testing relational tables.
Thnx, Davor
Have a look in BOL for INSERT...FROM.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
December 17, 2008 at 3:36 pm
Thnx Ten, for tip.
I have resolved the generation of the test data with INSERT INTO & cross join.
Davor
๐
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply