Chris McCall
Chris McCall

Reputation: 10407

SQL UDF in WHERE condition

I want to write a query kind of like this:

CREATE PROCEDURE DupFinder
@FirstName varchar(20),
@LastName varchar(20)

AS

SELECT CustId 
  FROM Cust c 
 WHERE [dbo].[fn_MatchConfidence](@FirstName + ' ' + @LastName,
                                  [dbo].fn_createCustHash (CustId)) > .8

Running the fn_MatchCondifence User-Defined Function (which takes two varchars and returns a number) over the entire Cust table. CreateCustHash just makes a string of FirstName and LastName with a space in the middle.

How can I do this?

Upvotes: 2

Views: 880

Answers (1)

Rob Farley
Rob Farley

Reputation: 15849

Don't use a Scalar function. They're really bad.

http://msmvps.com/blogs/robfarley/archive/2009/12/05/dangers-of-begin-and-end.aspx

Instead, use an inline table-valued function.

Upvotes: 6

Related Questions