Our company runs a MS Access Frontend and SQL Backend, and I'm trying to provide a stored procedure for the frontend that would allow it to have access to T-SQL's IF EXIST, instead of using DCount to improve performance. To do this I need to be able to pass the SELECT statement to the stored procedure, and so far I have the following code:
CREATE PROCEDURE [dbo].IfExists
@selectStatement varchar(MAX)
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS (@selectStatement)
RETURN 1
ELSE
RETURN 0
END
GO
which doesn't work because it doesn't like the @selectStatement instead of a hardcoded statement. Not sure how I can do this, any help would be appreciated.