2
Reply

Passing Table Parameter to a Table Function in SQL Server

suresh sarda

suresh sarda

Aug 9 2016 5:49 AM
187
I have create the table-function with table valued parmaeter. I am able to use it as below code
 
DECLARE @dimtypetable ddm.[VAR_DIMENSIONDETAILS] ;
INSERT INTO @dimtypetable
SELECT * FROM (VALUES('FAMILY',NULL,NULL,NULL,NULL,NULL),
('SUB_FAMILY',NULL,NULL,NULL,NULL,NULL)
)S(A,B,C,D,E,F)
--SELECT * FROM @dimtypetable
SELECT * FROM DDM.FN_GETDIMENSION_TBL(@dimtypetable);
 
Now I wan to use this table valued function as select statement using the Table-constructor thru cross apply or simple select statement.
 
SELECT * FROM DDM.FN_GETDIMENSION_TBL((SELECT * FROM (VALUES('FAMILY',NULL,NULL,NULL,NULL,NULL))S(A,B,C,D,E,F)));
 
Msg 116, Level 16, State 1, Line 1
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Msg 206, Level 16, State 2, Line 1
Operand type clash: varchar is incompatible with VAR_DIMENSIONDETAILS 
 

Answers (2)