bibi92
asked on
optimize sql statement
Hello,
How can I optimize this statement which takes time :
select * ,
(
select name
from [server].base.sys.schemas
where name = 'TESTS' and rowid not in (select ZROWID_0 from ods.schema.table where [ZDOS_0] = 'TEST')
) as [ZDOS_0] into #stmt_repl
from [server].base.schema.table
Thanks
bibi
How can I optimize this statement which takes time :
select * ,
(
select name
from [server].base.sys.schemas
where name = 'TESTS' and rowid not in (select ZROWID_0 from ods.schema.table where [ZDOS_0] = 'TEST')
) as [ZDOS_0] into #stmt_repl
from [server].base.schema.table
Thanks
bibi
ASKER
7332245rows and 2345673rows
Thanks
Regards
bibi
Thanks
Regards
bibi
Not sure if this will help
DECLARE @name sysname -- change datatype if need to
SELECT @name = name FROM [server].base.sys.schemas WHERE name = 'TESTS'
SELECT *, @name as [ZDOS_0]
INTO #stmt_repl
FROM [server].base.schema.table
UPDATE #stmt_repl
SET x = NULL
FROM ods.schema.table OST
WHERE #stmt_repl.rowid = OST.ZROWID_0 -- if field name is not rowid, change it to the correct one
AND OST.ro = 'TEST'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks bibi
SELECT COUNT(*) FROM [server].base.sys.schemas WHERE name = 'TESTS'
SELECT COUNT(*) FROM ods.schema.table WHERE [ZDOS_0] = 'TEST'
Since I'm wonder why it will take some significant process time.