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
 Transact-SQL (2000)
 UDF calling an extended stored procedure

Author  Topic 

Trent
Starting Member

39 Posts

Posted - 2006-01-13 : 12:57:48
I have a function (part of the code is below) that uses the extended stored procedure sp_executesql

It gives me the following error:
Only functions and extended stored procedures can be executed from within a function.

Doesn't that error mean that this should work?
Thank you for any help!

DECLARE @TableName nvarchar(64)
DECLARE @SQLString nvarchar(1800)

declare @TransX varchar(6)
select @TableName = 'S' + @StudyNo
select @SQLString = 'select top 1 @TransX = TransX from MData.dbo.' + @TableName + ' where DatabaseID = ' + @TesterID + ''

execute sp_executesql @SQLString, N'@TransX varchar(6) out', @TransX out

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-13 : 19:18:37
sp_executesql is not an extented stored procedure.

-----------------
'KH'

if you can't beat them, have someone else to beat them
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-01-13 : 20:29:38
quote:
Originally posted by khtan

sp_executesql is not an extented stored procedure.

-----------------
'KH'

if you can't beat them, have someone else to beat them



It is an extended stored procedure, and shows that way in Enterprise Manager.


CODO ERGO SUM
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-13 : 22:36:57
>> It is an extended stored procedure, and shows that way in Enterprise Manager.
Is it ? Always tot that extented SP are xp_

-----------------
'KH'

if you can't beat them, have someone else to beat them
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-13 : 22:45:04
MVJ, you are right. sysobjects.xtype is 'X' for sp_executesql

-----------------
'KH'

if you can't beat them, have someone else to beat them
Go to Top of Page
   

- Advertisement -