Hi, On executing a function return below error
Msg 557, Level 16, State 2, Line 1
Only functions and some extended stored procedures can be executed from within a function.
Create procedure [dbo].[sp_EmailCHk] (@email varchar(100))
as
insert into dbo.Email(Email_Email) values(@email)
GO
CREATE function [dbo].[fn_ChkEmail]
(
@email varchar(2000)
)
returns int
AS
begin
declare @status varchar(1)
SELECT @status = count(*) from Email where Email_Email=@email
if @status=0
begin
exec sp_EmailCHK @email
end
return (select @status)
end
GO
select [dbo].[fn_ChkEmail] ('useremail@gmail.com')