Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Insert 3 columns

Author  Topic 

Nowy
Yak Posting Veteran

57 Posts

Posted - 2007-06-08 : 08:23:59
I have written an function that returns 3 values.

How can I put this values in an new table? Separate about 3 columns

What I do now, is write 3 difference functions that returns 1 value. So I execute 3 functions in sequence, to put it in an new table. But in this way I loss performance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-06-08 : 08:24:53
insert into #temptable
select col1, col2, col3 from dbo.fnMyFirstFunction(12)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Nowy
Yak Posting Veteran

57 Posts

Posted - 2007-06-08 : 08:40:42
thnx
Go to Top of Page

Nowy
Yak Posting Veteran

57 Posts

Posted - 2007-06-08 : 09:50:15
but by "UPDATE" I have to execute the function 3 times?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-08 : 09:54:44
quote:
Originally posted by Nowy

but by "UPDATE" I have to execute the function 3 times?


No. You can INNER JOIN to the table


KH

Go to Top of Page

Nowy
Yak Posting Veteran

57 Posts

Posted - 2007-06-08 : 09:55:55
can you give me an example?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-08 : 09:57:32
[code]
update t
set col2 = f.col2,
col3 = f.col3
from #temptable t inner join dbo.fnMyFirstFunction(12) f
on t.col1 = f.col1
[/code]


KH

Go to Top of Page

Nowy
Yak Posting Veteran

57 Posts

Posted - 2007-06-08 : 10:00:56
thnx
Go to Top of Page
   

- Advertisement -