Showing posts with label Insert Data From One Table to Another Table. Show all posts
Showing posts with label Insert Data From One Table to Another Table. Show all posts

Thursday, July 17, 2014

Insert Data From One Table to Another Table

Before Inserting Data into table we have to consider if table is created or not.If Table is created then we use INSERT INTO SELECT method and in another case SELECT INTO TABLE.

INSERT INTO SELECT  :

INSERT INTO [dbo].[Rpt_WeeklySales]
([Description],[Value],[Week_No],[Year],[fkPartyId])
SELECT B.Description, A.Order_Val, A.Week_No,A.Year,A.fkParty_Id
FROM dbo.Trans_Order as A INNER JOIN dbo.SA_TRANS_ORDER_DETAIL as B
ON A.Order_Id = B.Order_Id

SELECT INTO TABLE :
SELECT B.Description, A.Order_Val as Value, A.Week_No,A.Year,A.fkParty_Id
INTO TestTable
FROM dbo.Trans_Order as A INNER JOIN dbo.SA_TRANS_ORDER_DETAIL as B
ON A.Order_Id = B.Order_Id