这更像是一个语法问题,我正在尝试编写一个可以嵌入到查询中的存储过程或函数,例如:
select * from MyBigProcOrFunction
Run Code Online (Sandbox Code Playgroud)
我正在尝试定义一个表格函数,但我不明白如何做到这一点,因为我构建tmp表来计算数据,然后我终于在endtable返回了.我的代码标记是:
create function FnGetCompanyIdWithCategories()
returns table
as
return
(
select * into a #tempTable from stuff
'
etc
'
select companyid,Company_MarketSector from #tempTables 'the returning table data
)
Run Code Online (Sandbox Code Playgroud)
如果我定义一个函数,我该如何将它作为表格返回?