December 17, 2003 at 3:46 am
Which of the commands below has better performance in Sql Server 2000
1) If Not Exists(Select Cliente.CD_Cliente From Cliente Where Cliente.CD_Cliente = @CD_Cliente)
or
2) If (Select count (*) From Cliente Where Cliente.CD_Cliente = @CD_Cliente) = 0)
I am using this commands inside of Store Procedure, or other form would exist of executing this better command.
Thankful at once.
Claudinei
Brazul Transport of Vehicles Ltd.
Visual Basic
Sql Server
ASP
Visual Basic
Sql Server
ASP
December 17, 2003 at 3:56 am
I would say, that EXISTS almost always performs better, because it can stop once the logical test is true, while COUNT walks through the whole resultset, even after the condition is met.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply