I'm passing View name as parameter in a Table Valued Function, and I want to fetch some data from that view by building a dynamic SQL and executing it by sp_executesql(). when try to execute the function, I get the error: Only functions and extended stored procedures can be executed from within a function.
DBMS: SQL Server 2005
any workarounds?
set @SQLString = N'select @Desc = Description from '+ @TableName + ' where Code = @Code;'
execute sp_executesql @SQLString, N'@Code nvarchar(500), @Desc nvarchar(500) OUTPUT', @Code = @Code, @Desc=@Desc OUTPUT;