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 2008 Forums
 Other SQL Server 2008 Topics
 Evaluate Math Expressions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Soumasree
Starting Member

1 Posts

Posted - 05/16/2012 :  08:42:50  Show Profile  Reply with Quote
Hi,

I want a procedure or a function where I'll pass some parameters and get the result of expression (generated in the process). I will be saving the expression result in a seperate table to proceed with other activities.

I am unable to create a function because it doesn't allow the "EXEC" command.

I am unable to use stored procedure because I will be calling this from a select statement.

What shall I do ?

visakh16
Very Important crosS Applying yaK Herder

India
47173 Posts

Posted - 05/16/2012 :  20:57:01  Show Profile  Reply with Quote
why do you need EXEC command? also if you want to store it in a table then you should be doing this in procedure itself as UDF doesnt allow DML modifications.
Could you elaborate on what exactly you're trying to do and how you want it to be called from SELECT?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

godestalbin
Starting Member

2 Posts

Posted - 05/21/2012 :  23:47:07  Show Profile  Reply with Quote
I think I have exactly the same need:
I want to run a statement like:
select ItemID, dbo.CalculatedAttribute( ItemID, AttributeID )
from Item
The function will get formula and data from database to retrieve data (related to ItemId) and formula (related to AttributeID) for the specified ItemId and AtttributeId:
For instance formula could be Length x Width so it will build a string with data from database like '60 * 30' and should return the result.
Formula could be more elaborated.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47173 Posts

Posted - 05/22/2012 :  00:09:30  Show Profile  Reply with Quote
quote:
Originally posted by godestalbin

I think I have exactly the same need:
I want to run a statement like:
select ItemID, dbo.CalculatedAttribute( ItemID, AttributeID )
from Item
The function will get formula and data from database to retrieve data (related to ItemId) and formula (related to AttributeID) for the specified ItemId and AtttributeId:
For instance formula could be Length x Width so it will build a string with data from database like '60 * 30' and should return the result.
Formula could be more elaborated.


this is not a good way of implementing requirement. why are you storing formula as value itself? why not separate different attributes out into different column? what meaning does it have to keep different things under same column?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.05 seconds. Powered By: Snitz Forums 2000