Please help me with the below mentioned scenarios->
Data is ->
Now I need to dump data from Table B into table A using two ways
Scenario 1) I needs to dump all data from Table B into table A at last row of Table A but condition is that the the Eid column of first row of Table B should contain value with Max of Eid column value + 1 of Table A
from above data Eid column of table A has max value as '103' so the first record of table B should inserted into table B with Eid column value as 104 and subsequently all records of table B should be inserted in the same way.
O/P required ->
Scenario 2) I needs to dump all data from Table B into table A at a specific row of Table A but condition is that the the Eid column of first row of Table B should contain value of (+1) the value of Eid column value of Table A at that specific row
Suppose I need to dump data into table A at row with Eid column value as as '102' so the first record of table B should inserted into table A with Eid column value as '103' and subsequently all records of table B should be inserted in the same way and after that the other records of table A should be updated acoordingly
For above data,If I insert data at row with eid as '102' of Table A all data from table B should be insered after that specific row and after that insert operation ,remaining data from table A like rows that were earlier like eid of '103' should be updated with max of value of eid columns + 1 that was calculated after the insert operation
Hope I was able to clarify my query.
Immediate response would be much appreciated.
Query to recover accidentally deleted data
Here are two solutions (one per scenario):
Insert the data from one table into the other, generating new eid values on the way in (works for SQL 2005 and above).
Here I am assuming that eid is the driving value in each table and that the id column has no meaning other than to be a primary key.
Next comes scenario 2:
Insert the values from one table into another, between rows in the target table, renumbering eid values that are "pushed down" the target table.
This solution runs some changes inside a transaction and rolls the transaction back - you will want to change the rollback into a commit once you are sure that the data is being changed as you want it to.
That should allow you to either add all the data to the end of the table or in between current values.
answered Mar 23 '12 at 08:58 AM