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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-03-06 : 07:34:08
|
| Nikhil writes "The purpose of this function is to pass the tablename as a variable to the function and then select the OUTPUT variable into @items. This works as a stored procedure but in case of UDF it gives the following error:"Only functions and extended stored procedures can be executed from within a function".CREATE Function dbo.func_test (@rule_def varchar(50))Returns varchar(50)ASBEGINDeclare @items varchar(50)Declare @strsql nvarchar(100), @paramdef nvarchar(100)Set @strsql = N'Select @_items = Select items From '+@rule_def+' Where rule_no = @_rule_no AND LorRHS = @_LorR' @_LorR, @_items OUTPUT'Exec sp_executesql @strsqlReturn @itemsEND" |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-03-06 : 10:48:24
|
| Check out BOL:CREATE FUNCTIONCreates a user-defined function, which is a saved Transact-SQL routine that returns a value. User-defined functions cannot be used to perform a set of actions that modify the global database state. User-defined functions, like system functions, can be invoked from a query. They also can be executed through an EXECUTE statement like stored procedures.User-defined functions are modified using ALTER FUNCTION, and dropped using DROP FUNCTION. |
 |
|
|
|
|
|