SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Insert 3 columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Nowy
Yak Posting Veteran

57 Posts

Posted - 06/08/2007 :  08:23:59  Show Profile  Reply with Quote
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

Sweden
30208 Posts

Posted - 06/08/2007 :  08:24:53  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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 - 06/08/2007 :  08:40:42  Show Profile  Reply with Quote
thnx
Go to Top of Page

Nowy
Yak Posting Veteran

57 Posts

Posted - 06/08/2007 :  09:50:15  Show Profile  Reply with Quote
but by "UPDATE" I have to execute the function 3 times?

Edited by - Nowy on 06/08/2007 09:50:39
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17598 Posts

Posted - 06/08/2007 :  09:54:44  Show Profile  Reply with Quote
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 - 06/08/2007 :  09:55:55  Show Profile  Reply with Quote
can you give me an example?
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17598 Posts

Posted - 06/08/2007 :  09:57:32  Show Profile  Reply with Quote

update t
set    col2 = f.col2,
       col3 = f.col3
from   #temptable t inner join dbo.fnMyFirstFunction(12) f
on     t.col1 = f.col1



KH

Go to Top of Page

Nowy
Yak Posting Veteran

57 Posts

Posted - 06/08/2007 :  10:00:56  Show Profile  Reply with Quote
thnx
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000