sql server - How to select from a table function along with columns from another table -


i have function returns table. takes 1 parameter , returns 1 row.

i want select values function along columns table in same select staement.

something this:

select a.col1, a.col2, b.col1, b.col2 tab1 inner join      func1(a.col1) b on a.col1 = b.col1 a.col1 in (123,456,789) 

this doesn't work, there way can this.

so, example, if func 1 returns following each of 3 values in example:

col1  col2 123   abc 456   def 789   xyz 

then expecting following results query:

col1  col2  col1  col2 123   xxx   123   abc 456   yyy   456   def 789   zzz   789   xyz 

i can this, i'd rather not call function multiple times each column want function:

select col1, col2, (select col1 func1(a.col1)), (select col2 func1(a.col1)) tab1 a.col1 in (123,456,789) 

this code true

alter  function gettable() returns  @rtntable table  (     sum_cd nvarchar(15) not null,     name nvarchar(255) not null ) begin declare @temptable table (sum_cd nvarchar(15), name nvarchar(255))  insert @temptable(sum_cd,name) values ('300001','ahmed') insert @temptable(sum_cd,name) values ('300002','mohamed')  insert @rtntable select * @temptable return end  select *   glsums g inner join dbo.gettable() s on s.sum_cd=g.sum_cd 

in sql server 2012


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -