How can I write a stored procedure to return if a table exist or not?
I put:
Code:
CREATE procedure sp_BA_ReportExist
(
@ISYES VARCHAR (10),
@ISNO VARCHAR (10)
)
AS
DECLARE @SQL varchar(8000)
SET @SQL = " if object_id('BA_REPORT_MASTER') is not null RETURN "+@ISYES+" ELSE RETURN "+@ISNO+" "
EXEC(@SQL)
GO
I ran it with: sp_BA_ReportExist '1','0'
but I get:
Code:
Server: Msg 178, Level 15, State 1, Line 1
A RETURN statement with a return value cannot be used in this context.
Server: Msg 178, Level 15, State 1, Line 1
A RETURN statement with a return value cannot be used in this context.
How can I make this work?
Thanks!
Ken