How can I write this Table Valued Function as a Stored Procedure?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-24T17:02:20Z Indexed on 2010/05/24 17:11 UTC
Read the original article Hit count: 198

Filed under:
|

I have the following TVF for fulltext search:

FUNCTION [dbo].[Fishes_FullTextSearch]
(@searchtext nvarchar(4000), @limitcount int)
RETURNS TABLE
AS
RETURN 
SELECT * FROM Fishes
INNER JOIN CONTAINSTABLE(Fishes, *, @searchtext, @limitcount)
AS KEY_TBL ON Fishes.Id = KEY_TBL.[KEY]

When I'm using this TVF, it doesn't return a collection of objects of type Fish (which I want!) - instead LINQ creates a new result type which includes all "Fish" fields and the fields Key and Rank.

In another question, it was suggested that I rewrite this TVF into a stored procedure for it to return Fish objects only. Can someone help me do this please? Also, it needs to be ordered by Rank.

Thank you!

© Stack Overflow or respective owner

Related posts about sql

Related posts about table-valued-function