I have 3 tables (accnt
, jobcost
, and servic15
). all with the same fields (code
, jno
, ven
, date
). I need to insert the data from these tables into another table called dummy with the same fields, in one query. how do I do this?
i have used 3 separate insert into statements that look like this: but i need it in one statement:
INSERT INTO dbo.dummy
SELECT
dbo.jobcost.code,
dbo.jobcost.ven,
dbo.jobcost.date,
dbo.jobcost.jno,
FROM
dbo.jobcost
WHERE
dbo.jobcost.jno > '40000'
INSERT INTO dbo.dummy
SELECT
dbo.servic15.code,
dbo.servic15.ven,
dbo.servic15.date,
dbo.servic15.jno
FROM
dbo.servic15
WHERE
dbo.servic15.jno > '40000'
INSERT INTO dbo.dummy
SELECT
dbo.accnt.code,
dbo.accnt.ven,
dbo.accnt.date,
dbo.accnt.jno
FROM
dbo.accnt
WHERE
dbo.jobcost.jno > '40000'
You need INSERT ... SELECT statement
If the table is not created yet, use CREATE TABLE ... SELECT.