Hi,
I'm doing select statements on large tables (over 4 millions rec.) so performance is a big factor.
I have two select statement who are doing the same thing except the first one is not permitting me to update an existing table, it has to create it each time.
The second one is slower but permit me to update an existing table.
I always Truncate the table before lauching those select in a DTS package.
The first one wich is much faster is:
select top 100 PERCENT C.MANDT, C.MATNR, C.DATBI,C.DATAB, C.KNUMH into SAP_Repl.dbo.A980_test
from sbrosql1.SAP_Repl.dbo.MARA as B
inner join sbrosap2.PRD.dbo.A980 as C
on B.MATNR = C.MATNR
Where C.MANDT='100' and C.KAPPL='V' and C.KSCHL='Z020' and C.DATBI > '2004'
The second one wich permit me to update the table is:
INSERT INTO SAP_Repl.dbo.A980_test
(MANDT, MATNR, DATBI, DATAB, KNUMH)
select top 100 PERCENT C.MANDT, C.MATNR, C.DATBI,C.DATAB, C.KNUMH
from sbrosql1.SAP_Repl.dbo.MARA as B
inner join sbrosap2.PRD.dbo.A980 as C
on B.MATNR = C.MATNR
Where C.MANDT='100' and C.KAPPL='V' and C.KSCHL='Z020' and C.DATBI > '2004'
What is the performance difference with those 2 select statements and is it possible to use the first one without having to drop the table each time ?
I'm doing select statements on large tables (over 4 millions rec.) so performance is a big factor.
I have two select statement who are doing the same thing except the first one is not permitting me to update an existing table, it has to create it each time.
The second one is slower but permit me to update an existing table.
I always Truncate the table before lauching those select in a DTS package.
The first one wich is much faster is:
select top 100 PERCENT C.MANDT, C.MATNR, C.DATBI,C.DATAB, C.KNUMH into SAP_Repl.dbo.A980_test
from sbrosql1.SAP_Repl.dbo.MARA as B
inner join sbrosap2.PRD.dbo.A980 as C
on B.MATNR = C.MATNR
Where C.MANDT='100' and C.KAPPL='V' and C.KSCHL='Z020' and C.DATBI > '2004'
The second one wich permit me to update the table is:
INSERT INTO SAP_Repl.dbo.A980_test
(MANDT, MATNR, DATBI, DATAB, KNUMH)
select top 100 PERCENT C.MANDT, C.MATNR, C.DATBI,C.DATAB, C.KNUMH
from sbrosql1.SAP_Repl.dbo.MARA as B
inner join sbrosap2.PRD.dbo.A980 as C
on B.MATNR = C.MATNR
Where C.MANDT='100' and C.KAPPL='V' and C.KSCHL='Z020' and C.DATBI > '2004'
What is the performance difference with those 2 select statements and is it possible to use the first one without having to drop the table each time ?