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 2005 Forums
 Transact-SQL (2005)
 How To Execute A UDF inside a stroed procedure?

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2008-02-20 : 09:19:54
hi,
here i am writting a storedprocedure sp_test. i have a UDF which accepts two i/p parameters and returns table. so how i can call n execute this UDF inside a procedure. i will send i/p parameters for UDF from procedure. after returning table from UDF in which data type i have to recive in stored procedure.
pls help me on this

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-20 : 09:32:11
You can consider table returned from UDF as normal table:

Select * from dbo.UDF_test(@param1, @param2)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2008-02-20 : 09:37:33
hi,
Thank you for giving the solution.
i need to get to get the each record from the table(i.e table returned by UDF) n need to perform some operations in the same procedure.

in that case, how i have to store it in my procedure n access it. i.e what will be the definition of parameter which i have to provide to receive the table from UDF

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-20 : 09:42:06
You can either store the table returned by UDF in table variable or Temp table.

Declare @Temp table
(
col1 ..,
col2 ..,
...
)

insert @Temp
Select * from dbo.UDF_test(@param1, @param2)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2008-02-20 : 09:48:36
hi,
is there any command to get row by row from table in sqlserver 2005.
my task is specifically:
i need to get the all row values at column1 of this table one by one n need to pass to another query.
is there any way?

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-20 : 09:51:46
If you can describe whole scenario, we may be able to help find out solution.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2008-02-20 : 10:06:15
hi,
i have three tables named table1,table2,table3:
table1 rough data:
id val
1 1
2 3
5 4

table2 rough data:
id val
7 9
10 23
13 34

table3 strucutre:
id1 int foreign key to table1
id2 int foreign key to table2

here from table3 i need to get the values of id1,id2 n need to perform addition operation of that values n need to match with integer 25.

if first match sum is say 18, then it need add next match sum to this value i.e if second match sum is 7 then 18 + 7 = 25 satisfied then it needs to return this two rows.

so i need to perform this operation untill n unless i get the 25(example).

please suggest me a way



One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-20 : 10:46:03
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80857




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -