Apply scalar function to each row
I have a function that works l开发者_C百科ike this: select score from comparestrings(@String1,@string2)
The code of function is below:
ALTER FUNCTION
[dbo].[BlockDistance](@firstword [nvarchar](255), @secondword [nvarchar](255))
RETURNS [float] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [TextFunctions].[StringMetrics].[BlockDistance]
Is comparestrings a UDF that returns a table?
Instead, just make it return a scalar value and do this:
select comparestrings(@string1, tablestring) from yourtable
Don't call it row by row.
Store it row by row with a computed column if the inputs are constants or columns from the same row.
ALTER TABLE Mytable ADD
Score AS comparestrings(Col1,Col2)
Then you can PERSIST it and index it too
加载中,请稍侯......
精彩评论