NameSearch SQL Server 2000 SDK
NameSearch
comes with Microsoft SQL Server Software Developer’s Kit that contains
numerous examples of calling the software functions from within
Transact-SQL (T-SQL) code. The SDK also includes a specialized
dynamic link library.
NameSearch
functions can be called from any T-SQL scripts by means of extended stored
procedures
and user-defined functions (UDFs). A function is ready to be
utilized as soon as corresponding extended stored procedure, or a UDF,
are registered
with SQL Server. Here is a simple example of registering such
a procedure with the dynamic link library provided. This procedure will
call a key-generating
Matcher routine.
• Open
Microsoft SQL Server Enterprise Manager
• Connect to the server that you will be using
• Open DATABASES folder and go to the ‘master’ database
• Right-click on EXTENDED STORED PROCEDURES
• Click on NEW EXTENDED STORED PROCEDURE
• In the ‘Name’ field, type xp_MatcherCall
• In the ‘Path’ field, type the path to your NameSearch DLL
• Click ‘OK’
• The functionality can now be utilized underneath SQL-Server
EXAMPLE OF CALLING
NameSearch Matcher function FROM T-SQL:
exec [master].dbo.xp_MatcherCall
'name1', 'bob Smith', @Nameout OUTPUT, @wst OUTPUT, @pst OUTPUT,@kcount
OUTPUT,@kst OUTPUT,@ktable OUTPUT
PRINT @kst
PRINT 'Key stack generated successfully!'
The
following example demonstrates how the Alfacomp comparison
routine can be called
as a SQL-Server user-defined function (you will note that this
function requires two extended stored procedures – xp_alfacomp and xp_stats – to
be registered with the SQL-Server):
STEP 1: Creating
the function
CREATE FUNCTION
ISTALFACOMP(@istName1 varchar(60), @istname2 varchar(60))
RETURNS varchar(3)
AS
BEGIN
DECLARE @scrArray varchar(12)
DECLARE @maxval varchar(3)
DECLARE @minval varchar(3)
DECLARE @avgVal varchar(3)
DECLARE @medVal varchar(3)
exec [master].dbo.xp_alfacomp @istName1,@istname2,@scrArray OUTPUT
exec [master].dbo.xp_stats @scrArray, '111100000000000000', @maxval OUTPUT,
@minval OUTPUT, @avgVal OUTPUT, @medVal OUTPUT
RETURN(@avgVal)
END
STEP 2: Executing
the function
DECLARE @word1
varchar(256)
DECLARE @word2 varchar(256)
DECLARE @scoreout char(3)
set @word1 =
'bob Smith'
set @word2 = 'robert smith'
set @scoreout = master.dbo.ISTALFACOMP(@word1, @word2)
PRINT @scoreout
PRINT 'Scores output successfully!' NameSearch® General Information
|