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 2005 Forums
 Transact-SQL (2005)
 Use of EXECUTE() inside UDF

Author  Topic 

KurtW
Starting Member

6 Posts

Posted - 2007-04-10 : 13:52:01
Hi all:

I know you can use EXECUTE() inside of a sproc, but what about inside a UDF? Mine seems to choke and I believe the error means no go inside a UDF, but I wanted to make sure I just wasn't doing it wrong.

Thanks

Kurt

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-10 : 13:56:43
You are not wrong. You normally can't use EXEC in a function.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-04-10 : 15:21:48
You can probably use OPENQUERY or a separate OLEDB-style connection.

But IMO what's the point? It wasn't intended to do that, so why force ones way around the limitation? I think better to find a solution that works "as intended" with SQL server.

What's the particular scenario you are trying to problem-solve? Knowing that might enable us to make some suggestions.

Kristen
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-04-10 : 18:34:53
Ran into a similiar issue before, and after a ton of wasted time. I just ended up changing the queries in the sproc I wanted to execute into functions. Then just re-wrote the original sproc to select the new functions rather then duplicating the work. Performance didn't dencrease, and I saved a lot of time by using this approach, and it's clean because all your code is not duplicated throughout the db.
Go to Top of Page
   

- Advertisement -