I have a problem with My T-SQL to see if there is an EXISTS element in the table, but I have an error message
Msg 178, Level 15, State 1, Line 2 The RETURN return statement cannot be used in this context. Msg 178, Level 15, State 1, Line 4 The RETURN statement with return value cannot be used in this context.
IF EXISTS(SELECT COUNT(timesheetID) FROM [TaskManagementSystem_DB].[dbo].[Timesheet_entry] WHERE userID ='12' AND CONVERT(date, startTimeStamp)=CONVERT(date, getdate())) RETURN 1 else RETURN 0
All code:
ALTER PROCEDURE [dbo].[CheckTimesheetIsEXISTS_forUser] @UserID uniqueidentifier AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; IF EXISTS(SELECT COUNT(timesheetID) FROM [TaskManagementSystem_DB].[dbo].[Timesheet_entry] WHERE userID ='3fd971f7-e6e8-40fe-a90d-a7c9df8bf7b5' AND CONVERT(date, startTimeStamp)=CONVERT(date, getdate())) RETURN 1 else RETURN 0 END
user474901
source share