i have 4 tables.. T1, T2, T3, T4..
these tables have the same structure and they store the
information entered in different years..
T1 stored 2002, T2 stored 2003, T3 stored 2004 and T4 stored
2005..

i want to copy contents in T1 to T2, T2 to T3, T3 to T4 and
T4 to T1..
how do i do that? Temp tables cannot be used..

Answer Posted / deepak

Just copy all data in T1 from T4.

insert into T1 (select * from T4)

Now do this assuming 'dateCol' contains the date:

delete from T4
insert into T4 (select * from T3)
delete from T3
insert into T3 (select * from T2)
delete from T2
insert into T2 (select * from T1 where year(dateCol) = 2002)
delete from T1 where year(dateCol) = 2002

This should move the data around without using temp table.

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define ACID properties in a Database?

624


What command is used to rename the database?

524


Introduction of rollup clause using sum and group by clause?

532


How to set the current database in ms sql server?

522


You want to implement the one-to-many relationship while designing tables. How would you do it?

501






How to encrypt data between dialogs?

570


How to maintain a fill factor in existing indexes?

528


What is the ‘fillfactor’?

565


When would you use sql joins?

524


What are the different index configurations a table can have?

511


Explain the xml support sql server extends?

617


What is the difference between value type and reference type?

553


What is Federation and Federation Member?

80


Explain go command in sql server?

543


what are database files and filegroups? : Sql server database administration

497