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 query in Functions

Author  Topic 

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-07-27 : 01:30:03
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.

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2007-07-27 : 10:50:04
A function cannot internally save data to a permanent table.
From Books Online:
quote:
The only changes that can be made by the statements in the function are changes to objects local to the function, such as local cursors or variables. Modifications to database tables, operations on cursors that are not local to the function, sending e-mail, attempting a catalog modification, and generating a result set that is returned to the user are examples of actions that cannot be performed in a function.


e4 d5 xd5 Nf6
Go to Top of Page

sqlguru44
Starting Member

1 Post

Posted - 2007-07-28 : 22:41:29
Your function 1 should calculate the value and return it to its caller function 2 which then can use it. Can't pass it through a real data base table.

sqlguru44
http://www.helpolia.com
Go to Top of Page
   

- Advertisement -