sql server - T-SQL: How to use a user defined function with an table valued parameter from within a select statement -


i have following code convert records column of integer binary code:

create type t_table table(mycolumn int); go  create function func_test(@table t_table readonly) returns varbinary begin      ...      return <anything varbinary> end; go  select     x.id     ,dbo.func_test(         (select <anything int> <any table y> id = x.id)     )     <any table x> x group     x.id ; go 

but doesn't work. why can't use select statement parameter user defined function?

is possible without clr?

parameter of function func_test has of t_table type.

this work:

declare @t t_table; select func_test(@t) b; 

this not work:

declare @t table (mycolumn int); select func_test(@t) b; 

operand type clash: table incompatible t_table

tested on sql server 2014 express. guess, 1 of limitations of table-valued parameters.

as pointed out in comments, 1 possible workaround pass id parameter , perform actual query inside function.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -