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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to execute dynamic sql from user defined function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-22 : 07:39:16
Ganesh writes "I am trying to execute a dynamic query in a User Defined Function. But looks like sql server does not allow you to use "EXEC" statment in sql server user defined Functions to execute dynamic sqls.

E.g.


SELECT @SQL = 'SELECT * FROM '
SELECT @SQL = @SQL + @TableName

Exec ( @SQL)

I want to avoid Extended Store Procedure (can be written in VC++)"

mr_mist
Grunnio

1870 Posts

Posted - 2003-07-22 : 08:21:24
From BOL..

quote:

...generating a result set that is returned to the user are examples of actions that cannot be performed in a function.



My guess is that that falls under generating a result set.

What is the purpose of the function, maybe there is a better way to do it.


-------
Moo. :)
Go to Top of Page
   

- Advertisement -