I have created a function with Transact-SQL that after the ISBN of a book returns 1 (if it exists) or 0 (if it does not exist), but calling the function gives me an error. The code:
CREATE FUNCTION fn_llibre_ok (@isbn varchar(13)) returns bit AS
begin
declare @existeix bit
if exists (select lib_isbn from llibre where lib_isbn = @isbn)
begin
set @existeix = 1
end
else
begin
set @existeix = 0
end
return @existeix
end
I call the function with an ISBN that exists in the database:
select fn_llibre_ok('978-84-938011')
And I get this error
Msg 195, Level 15, State 10, Line 1
'fn_llibre_ok' no es un nombre de función reconocido.
I do not know if the function is wrong or that I do not call it well. If someone can give me a hand I would appreciate it