Article ID: 184497
Article Last Modified on 10/3/2003
USE pubs
GO
PRINT 'The following processes will test WITHOUT an index on
titleauthors'
PRINT 'Dropping constrainst on titleauthor table'
alter table titleauthor drop constraint UPKCL_taind
alter table titleauthor drop constraint FK__titleauth__title__14070484
PRINT 'Dropping index on titleauthor table'
drop index titleauthor.auidind
drop index titleauthor.titleidind
go
------------------------------------------------------------------------
-- Executing the query with a WHERE EXISTS on dynamic forward only
-- cursor
------------------------------------------------------------------------
PRINT 'Executing the base query a dynamic forward only cursor'
DECLARE avtest CURSOR FOR
SELECT au_lname
, au_fname
FROM authors a
, titleauthor ta
WHERE
a.au_id = ta.au_id
AND
EXISTS -- OR use NOT EXISTS
(
SELECT *
FROM publishers p
WHERE a.city = p.city
)
DECLARE @count int
SELECT @count = 0
OPEN avtest
FETCH NEXT FROM avtest
WHILE (@@FETCH_STATUS <> -1)
BEGIN
FETCH NEXT FROM avtest
select @count = @count + 1
END
CLOSE avtest
DEALLOCATE avtest
select @count
PRINT 'Please run the instpubs.sql script to reinstall the pubs
database'
Additional query words: SP SP3
Keywords: kbbug kbpending KB184497