I am creating a stored proc, it queries the table "Entries". The proc has the parameters @ID, which is an int, and @APPROVED, which is a bit. I'm using SQL Server 2005
If approved is false I want to do something different than if it is true. I have the following written. When I try to create it I get "Incorrect syntax near the keyword 'END'.".
If I remove the nested if the error goes away however from what I've read this is perfectly valid syntax. Could anyone tell me where I am going wrong?
CREATE Procedure [dbo].[GetEntry](@ID int,@APPROVED bit)
AS
IF @APPROVED = 0
BEGIN
--see if the unapproved entry has already been viewed
IF (SELECT COUNT(*)
FROM [dbo].[Entries]
WHERE EntryId = @ID AND Approved = @APPROVED AND Viewed = 0) > 0
BEGIN
END
END
Any help would be really appreciated. Thanks!
BEGINEND, something needs to be in there