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

What objects does the fn_my_permissions function reports on? : sql server security

747


When does the auto update index statistics feature in sql server turn itself on?q) what specific conditions database should meet, before you can bulk copy data into it using bcp?

756


Explain syntax for disabling triggers?

706


How to Check if table exists in sql server?

786


What is the process of normalization?

760






How to add the custom code in Report?

112


How to write an inner join with the where clause in ms sql server?

755


What are the different types of data sources in ssrs?

165


What is the difference between Stored Procedures and triggers?

790


What is data compression?

733


Explain relational data?

701


How the authentication mode can be changed?

846


What is the purpose of floor function?

748


What is the difference between system objects and user objects?

884


How to insert and update data into a table with "insert" and "update" statements?

699