Thursday, 16 August 2012

How to copy data from one table to another in oracle / sql server

// Correct Query to copy data from one table to another where column name not same

INSERT INTO [TestApp].[dbo].[Table_1]SELECT
 [table_two_col1] as [table_one_col],[table_two_col2] as [table_one_col2],
[table_two_col3] as [table_one_col3]
FROM [TestApp].[dbo].[table_2]








//Following query useful for only Copy data from one table to another

2)   

INSERT
INTO  [TestApp].[dbo].[Table_1]VALUES
( SELECT
 [table_two_col1] ,[table_two_col2],[table_two_col3]  FROM [TestApp].[dbo].[table_2]
)



3) 


SELECT  [table_two_col1] ,[table_two_col2],[table_two_col3]
into [TestApp].[dbo].[Table_1]
FROM [TestApp].[dbo].[table_2]


Try it... :)

No comments:

Post a Comment