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.
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/
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.
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/