-
transfering data from one table to another table
If we are transfering data from one table to another table say for ex transfering 1000 rows from one table to another table, how we can find whether all the rows are transfered.
-
Anothe interview question? You should spend time to read some sql basic books. Anyway, you can query target table.
-
How are you transferring it? Did you use
INSERT INTO tableB
SELECT FROM tableA
If it fails then you get an error, otherwise it succeeded. You can check the row count on tableB.
-
No By triggers we transfer from one table to another. Is there any way to transfer the data from one table to another.
-
You can use above mentioned statement, or use dts package.
-
Maybe I don't fully understand your question...but get a count of the source table prior to data load, then get a count of the target table after the load, and compare. count1 = count2, then successful.
-
To transfer data from one table1 to table2 by way trigger
Nisha, i hope i understood your question of transfering data from one table to another.To answer your question, i will say YES.By way of trigger, it means that data will automatically be transferred or inserted in table2 as the result of a delete,update or insert from table2. In my code, u will see that only data inserted in table1 will be transferred or inserted in table2(row by row).Assuming that you have two tables(table1 and table2)
and tb1id,tb2id as primary keys respectively for each table.
Then the trigger will be:
CREATE trigger trig1
on table1
for insert as
DECLARE @tb1ID numeric(9), @count int
SELECT @tb1ID=ins.@tb1ID,
@count=count(*)
FROM inserted ins WHERE ins.@tb1ID not in (select @tb2ID from table2)
GROUP BY ins.@tb1ID
if @count =1
begin
insert into table2(tb2id) Select tb1id FROM table1 WHERE tb1id=@tb1id
end
On the other hand, we can do a buck insert;that's
insert into table1 select name_offield from table2
without any where clause.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|