how can i decide this problem?
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[GetDataById] ()
RETURNS INT
AS
BEGIN
DECLARE @query NVARCHAR(500)
DECLARE @j INT
SET @query=N'select * from catalog'
EXEC sp_executesql @query
RETURN @j
END
When I try to exec this one: select dbo.GetDataById()
I get an error message:
Only functions and extended stored procedures can be executed from within a function.