I have Problem with My T-SQL to see if the item EXISTS on the table but I have the error message
Msg 178, Level 15, State 1, Line 2 A RETURN statement with a return
value cannot be used in this context. Msg 178, Level 15, State 1, Line
4 A RETURN statement with a 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
The whole 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
Try this: