I have a procedure which takes two parameters and I want to get the primary key values of those two parameters from two different tables and insert into a new table.
Now Name1 and name 2 are the parameters for the procedure and I have to get ID1 and ID2 from Tbl1 and Tbl2 and insert into a new table along with current date. There is no relation between Tbl1 and Tbl2 so that I can't go for joins.
WHERE Name1 = @parm1
WHERE Name2 = @parm2
Since there is no relation between the tables - you may find that you have the same ID values from both tables. If so - you need to add something to identify which source provided the data or change to UNION ALL which will create duplicate rows in the destination.
My actual requirement is like I have a User table with UserID and UserName, Role table with RoleID and RoleName. Now I am assigning a role to the user from front end. So I will be passing UserName and Rolename from frontend. From that I have to select UserID and RoleID from the corresponding tables and store the IDs in a Mapping table.