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
 General SQL Server Forums
 New to SQL Server Programming
 Insert using functions

Author  Topic 

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-05-17 : 00:58:37
i have a multistatement table function which is called from storedProc and it calulates certain values and returns it. now iwant to insert these calculated values into other table can this be done?
SP is
Create Proc (@a int,@b int,@c int)
AS
Begin
Select * FRom dbo.func1(@a,@b,@c)

Fucntion is
Ceate Function dbo.Func(@a int,@b int ,@c int)
Returns @T table(@X int, @Y int, @Z int)
as
begin
set @X="Calculate"
Set @Y="Calculate"
set @Z="Calculate"
Insert Into @T Values(@X,@Y,@Z)
Return @T

Now i want to enter the values in table @T into some other table how do i do it?




khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-17 : 01:00:54
You have to use Stored Procedure. You can't do this in a function


KH

Go to Top of Page

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-05-17 : 01:03:31
the table values @T is returned in storedProc so how do i insert into other table the values in @T using stored proc
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-17 : 01:05:47
[code]
insert into sometalbe(x, y, z)
select x, y, z
from dbo.func1(@a,@b,@c)
[/code]


KH

Go to Top of Page

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-05-17 : 01:06:55
thank u,i appreciate ur help KHTan
Go to Top of Page
   

- Advertisement -