Hi all,
I have got a situation, where i have to create a table in the staging for look up purpose.
Here is the scenario.....Lets take Table A as source table, Table B as Target table and Table C as staging table.
** ID column of Table B is Identity column.
Table A
Table B
----------------------------------------- ---------------------------
| A_Code | Description | | ID | B_Code |
----------------------------------------- ---------------------------
| a | Australia | | 1 | a |
----------------------------------------- ---------------------------
| g | Germany | | 2 | g |
----------------------------------------- ---------------------------
Table C
--------------------------------------------------------
| A_Code | ID | Description |
--------------------------------------------------------
| a | 1 | Australia |
---------------------------------------------------------
| g | 2 | Germany |
---------------------------------------------------------
So first we insert one record from table A to Table B, the inserted record will generate an id (as ID is Identity column) , that id should be inserted in the staging table C with it corresponding Table A related values. Table C in staging should look like above, in my job i am not able to retrieve the last inserted record inserted in Table B.
I tried by taking Max of the Table B but didn't worked some mismatch happend when testing with different scenario.
I also tried tMSSQLLastInserted but its throwing exception(NullPointerException).
Can anybody help me to achieve this??