1
create function PRODUCT_CULC (@PRODUCT_KEY AS VARCHAR(50), @PROD_TABLE *AS TABLE*) RETURNS TABLE RETURN  SELECT

How do I get in table-valued function table as a input value? (What I wrote on the exemple are incorrect)

create function [db_123].[PRODUCT_CULC]

(@PRODUCT_KEY AS VARCHAR(50))

RETURNS TABLE
RETURN (
select TOP 3 ACCOUNT_KEY
From db_123.ORDERS ORD
 JOIN db_123.ACCOUNT ACCOUNT ON ORDERS.ACCOUNT_SK = ACCOUNT.ENTITY_SK
 JOIN db_123.PRODUCT PRODUCT ON PRODUCT.ENTITY_SK = ORD.PRODUCT_SK AND PRODUCT.PRODUCT_KEY = @PRODUCT_KEY

);

I want instead of using the "orders" table, get the name of a table on which I will do the query .. that could be the same function I will want to do in cases other than the table orders

0 Answers0