Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Performance question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-07-06 : 07:45:40
George writes "I was wondering if there is performance difference when using SET or SELECT to set a variable. For example:

Is this faster?
select top 1 @an_id = an_id
from SomeTable with(nolock)
where a_field = @a_field

Or is this faster?
set @an_id = (select an_id from SomeTable with(nolock) where afield = @a_field)

Thanks"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-06 : 07:57:39
Refer this
http://vyaskn.tripod.com/differences_between_set_and_select.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -