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)
 Dynamic SQL query in user defined function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-09-21 : 07:16:46
Asheesh writes "How can we have variable table name after 'FROM' in a select statement in user defined function?

For example, a user defined function has this statement:
select * from tablename
tablename is passed as parameter to this function"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-09-21 : 07:18:48
You can't, and it's a bad use of UDFs to try. Not to mention that it's easy to pass a non-existant table name to the function and cause an error.

If you want to select data from a table, use a plain old SELECT statement. No need for a function at all.
Go to Top of Page
   

- Advertisement -