Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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..

Answers were Sorted based on User's Feedback



i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the informa..

Answer / 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

i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the informa..

Answer / madhu sudhan g

Hiii

DELETE T1
OUTPUT DELETED.COLUMN1,DELETED.COLUMN2...
INTO T2
DELETE T2
OUTPUT DELETED.COLUMN1,DELETED.COLUMN2...
INTO T3
DELETE T3
OUTPUT DELETED.COLUMN1,DELETED.COLUMN2...
INTO T4

Is This Answer Correct ?    1 Yes 0 No

i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the informa..

Answer / siva

insert into T1
select *from t2
union/union all (without duplicates/with duplicates )
select *from t3

union/union all
select *from t4
.

Is This Answer Correct ?    0 Yes 0 No

i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the informa..

Answer / gaurav

dear u can do like

insert into t2 select * from t1
insert into t3 select * from t2
.
.
.
.
so on

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More SQL Server Interview Questions

What is the purpose of forms?

0 Answers  


How can I create a new template for import ? : sql server management studio

0 Answers  


What are “lock” hints?

0 Answers  


Is sql server free?

0 Answers  


Can we create clustered index on composite key?

0 Answers  


what is a transaction? : Sql server database administration

0 Answers  


How to select some specific columns from a table in a query in ms sql server?

0 Answers  


Difference Between varchar and nvarchar datatype?

3 Answers   Satyam,


How to change location of errorlog in SQL?

2 Answers   ABC, IBM,


What are the rules to use the rowguidcol property to define a globally unique identifier column?

0 Answers  


What is the order in which the sql query is executed?

0 Answers  


What is the difference between substr and charindex in the sql server?

0 Answers  


Categories