Click here to Skip to main content
14,920,219 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi I have 2 select statements.
I have to use cursor to insert those values into single table.

For Example:
TableA
S.No. Name
1 Name1
2 Name2
...

TableB
DateOfBirth FatherName
10-2-1988 FatherName1
10-9-1989 FatherName2
...


Expected:
Name FatherName
Name1 FatherName1
Name2 FatherName2
...

One select query for selecting Name in TableA, other query for selecting FatherName in TableB.
Finally these two fields to be inserted into third table which has Name and FatherName.
Posted
Comments
Maciej Los 7-Jun-13 3:46am
   
How to "recognize" who is whos father? ;)
Have you any key field?
Raja Sekhar S 7-Jun-13 4:49am
   
If you can Provide the Relation Between two Tables like Foreign Key/Primary Key.... it can be Solved using a Join Statement or an Inner Query.... Same as told by Maciej Los .....

1 solution

TableA
S.No. Name
1 Name1
2 Name2
...

TableB
DateOfBirth FatherName S.no
10-2-1988 FatherName1 1
10-9-1989 FatherName2 2

select name,fathername from tablea
inner join tableb on
tablea.[s.no]=tableb.[s.no]

Create a tables like this and to provide a relationship
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900