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
 Select statement inside UDf

Author  Topic 

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-07-26 : 03:15:58
iam trying to rerieve a certain value from one table
and i want to use that vaue inside a UDF
iam usinf a table valued function as i have to retireve no of values
Can i do something like this to retrieve the value

SET @Value=Select Value from Table WHERE xyz='some no.'
as this value is being calculated by some other fucntion and now this funcation has to use this at runtime.

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2007-07-26 : 04:37:42
Hi,
You can get the value from the table as
Select @Value = Value from Table WHERE xyz='some no.'
and can use this variable as a parameter to your table valued function


Go to Top of Page

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-07-26 : 04:55:04
i am trying to get the value from some other table in the same databse. wii this work in UDF
Select @Value = 'ColumnName' from SomeotherTable WHERE xyz='some no.
Go to Top of Page

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2007-07-26 : 05:11:37
it would be good if you can clearly mention what exactly are you trying to achive .. or post your udf.
Go to Top of Page

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-07-26 : 05:24:00
ok wht iam trying to do is
my Function 1 is calculatin some value 'Value1' and storing it in a Databsae Table.

Now my Function 2 wants to use that 'Value2' which is stored in Databse Table. I want to retrieve that 'Value2' so my Function2 can use it for further calculation

The UDF is as follows
CREATE FUNCTION Immediate
{somevalues}
Returns @Immediate Table

Declare x float,

Now i want to use the value2

Select @Value = 'ColumnName' from SomeotherTable
SET @x=@value
will this work.As botht fumction1 & 2 calculate and store at runtime.


Go to Top of Page
   

- Advertisement -