sql server 2008 - (How) Can I place a with sql query in a table value function? -


i put following query return of table value function.

;with org (    select id    org_unit    id = @id_org_unit    union    select parent_id    org_unit c      join org p on p.id = c.id )  select * org  

i tried create such function i'm resorting stored procedure in despair...

is possible create function return result?

create function test_func(@id_org_unit int) returns table return (   org (      select id      org_unit      id = @id_org_unit      union      select parent_id      org_unit c        join org p on p.id = c.id   )    select * org    ); 

sqlfiddle


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c# - Avoiding duplicate methods for Task and Task<T> -

javascript - Which segment of a polyline was clicked? -