sql - Executing a Table-Valued Function from a Stored Procedure with multiple Table-Valued Parameters being passed through? -


I have a stored procedure that performs some repetitive code, so I used to call a redundant code In the decision to make the ceremony. The problem I am facing is:

  Message 137, Level 16, State 1, Process Search, Line 98 should declare the scalar variable "@myTVP"  < / Pre> 

I am using a simple example of SQL code:

  make type [dbo] .textTable_type AS table ([text] [nvarchar] (36)) FUNCTION dbo.Search_fn (@textTable_type READONLY as @myTVP) Click Return as table (SELECT * myTVP) as return [DBO]. [Search] read as textTable_type @ IMTP as Start Search from dbo Search_fn (@myTVP) END Get inserted into textTable_type @TVP values ​​as DETP ('ABC') @TVP values ​​('123 ') Exec dbo.Search (@myTVP = @TVP) Go Drop Function Search_FN Find Drop Process  

If anybody can provide information, then it would be great!

(If you try to run this example, there are some additional errors, but that is the error. The problem is because the stored procedure can not be created.

Thanks .

This works for me (some go batch delimiter added Gone and deleted stored procedure call to field)

If it does not work for you, then compatibility level of your database Or is it?

create type [dbo] .textTable_type as table ([text] [novavarkar] (36)) Make functions dbo.Search_fn (textTable_type readonly as @myTVP) Return form In the table return (SELECT * myTVP) make the process [dbo] go [search] @ myTVP as textTable_type READONLY start SELECT * FROM dbo.Search_fn (@myTVP) Go END textTable_type @TVP values ​​as Dellp Insert ('ABC') into @TVP values ​​('123') exec dbo.Search@myTVP = @TVP Go DROP Functions [DBO]. Search_Fan Drop Process [D BO]. Search Drop Type [DBO] .textable_type

Comments