Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Possible this be helpful for you -</p> <p><strong>1.</strong></p> <pre><code>CREATE PROCEDURE [dbo].[proc_tblUserScheduleNewUpdateOnly] ( @Scheduleid BIGINT , @Contactid UNIQUEIDENTIFIER , @ScheduleDate DATETIME , @StartTime VARCHAR(20) , @EndTime VARCHAR(20) , @Location BIGINT , @Area BIGINT , @Room BIGINT , @Enddate DATETIME , @CurrentTime DATETIME , @ModifiedBy UNIQUEIDENTIFIER , @schedulefileidNew BIGINT ) AS BEGIN UPDATE dbo.tblUserScheduleNew SET Contactid = @Contactid , ScheduleDate = @ScheduleDate , StartTime = @StartTime , EndTime = @EndTime , location = @Location , Area = @Area , Room = @Room , LastModifiedDate = @CurrentTime , EndDate = @Enddate , ModifiedBy = @ModifiedBy , ScheduleFileId = NULLIF(@schedulefileidNew, 0) WHERE ScheduleID = @Scheduleid AND IsDeleted = 0 AND isActive = 1 RETURN 1 END </code></pre> <p><strong>2.</strong> </p> <pre><code>CREATE PROCEDURE [dbo].[proc_tblUserScheduleNewFutureUpdate] ( @StartDatePassed DATETIME , @EndDatePassed DATETIME , @StartTimePassed VARCHAR(20) , @EndTimePassed VARCHAR(20) , @CurrentDateTime DATETIME , @Scheduleid BIGINT , @Contactid UNIQUEIDENTIFIER , @Location BIGINT , @Area BIGINT , @Room BIGINT , @ModifiedBy UNIQUEIDENTIFIER , @schedulefileidNew BIGINT ) AS BEGIN IF CONVERT(DATE, @StartDatePassed, 101) &gt; CONVERT(DATE, @CurrentDateTime, 101) AND CONVERT(DATE, @EndDatePassed, 101) &gt; CONVERT(DATE, @CurrentDateTime, 101) AND CONVERT(DATE, @EndDatePassed, 101) &gt; CONVERT(DATE, @StartDatePassed, 101) BEGIN DECLARE @ResultForInsertUpdate VARCHAR(200) EXEC @ResultForInsertUpdate = dbo.proc_tblUserScheduleNewUpdateOnly @Scheduleid , @Contactid , @StartDatePassed , @StartTimePassed , @EndTimePassed , @Location , @Area , @Room , @EndDatePassed , @CurrentDateTime , @ModifiedBy , @schedulefileidNew RETURN @ResultForInsertUpdate END ELSE BEGIN RETURN 2 END END </code></pre> <p><strong>3.</strong></p> <pre><code>CREATE PROCEDURE proc_tblUserScheduleNewUpdateWithAllRoomsOption ( @StartDatePassed DATETIME, @EndDatePassed DATETIME, @StartTimePassed VARCHAR(20), @EndTimePassed VARCHAR(20), @CurrentDateTime DATETIME, @Scheduleid BIGINT, @Contactid UNIQUEIDENTIFIER, @Location BIGINT, @Area BIGINT, @Room BIGINT, @ModifiedBy UNIQUEIDENTIFIER, @schedulefileidNew BIGINT, @OldStartDate DATETIME, @OldEndDate DATETIME, @OldStartTime VARCHAR(20), @OldEndTime VARCHAR(20), @OldContactid UNIQUEIDENTIFIER, @OldLocation BIGINT, @OldArea BIGINT, @OldRoom BIGINT ) AS BEGIN DECLARE @row_count INT , @intFlag INT = 0 , @locationIdForLoop BIGINT , @AreaIdForLoop BIGINT , @RoomIdForLoop BIGINT , @ResultForInsertUpdate INT = 1 CREATE TABLE #tempTable (RowNum INT, LocationId BIGINT, AreaId BIGINT, RoomId BIGINT) IF @Area = 0 AND @Room = 0 BEGIN INSERT INTO #tempTable (RowNum, LocationId, AreaId, RoomId) SELECT ROW_NUMBER() OVER (ORDER BY LocationId DESC) RowNum , LocationId , AreaId , RoomId FROM dbo.tblroomnew a WHERE a.AreaId IN ( SELECT b.AreaId FROM dbo.tblareanew b WHERE b.LocationId = @Location ) SELECT @row_count = COUNT(1) , @intFlag = 1 FROM #tempTable WHILE (@intFlag &lt;= @row_count) BEGIN SELECT @locationIdForLoop = LocationId , @AreaIdForLoop = AreaId , @RoomIdForLoop = RoomId FROM #tempTable WHERE RowNum=@intFlag IF @ResultForInsertUpdate = 1 BEGIN IF EXISTS ( SELECT 1 FROM dbo.tbluserschedulenew WHERE CONVERT(DATETIME,ScheduleDate,101)=CONVERT(DATETIME,@OldStartDate,101) AND CONVERT(DATETIME,EndDate,101)=CONVERT(DATETIME,@OldEndDate,101) AND CONVERT(TIME,StartTime,108)=CONVERT(TIME,@OldStartTime,108) AND CONVERT(TIME,EndTime,108)=CONVERT(TIME,@OldEndTime,108) AND contactid=@OldContactid AND location=@OldLocation AND Area=@OldArea AND Room=@OldRoom ) BEGIN PRINT 'Update First record' EXEC @ResultForInsertUpdate=proc_tblUserScheduleNewFutureUpdate @StartDatePassed , @EndDatePassed , @StartTimePassed , @EndTimePassed , @CurrentDateTime , @Scheduleid , @Contactid , @locationIdForLoop , @AreaIdForLoop , @RoomIdForLoop , @ModifiedBy , @schedulefileidNew RETURN @ResultForInsertUpdate END ELSE BEGIN EXEC proc_tblUserScheduleNewLatestInsert @Contactid , @StartDatePassed , @StartTimePassed , @EndTimePassed , @locationIdForLoop , @AreaIdForLoop , @RoomIdForLoop , @EndDatePassed , @ModifiedBy , 0 , @CurrentDateTime END END ELSE BEGIN RETURN @ResultForInsertUpdate END SELECT @intFlag = @intFlag + 1 END END ELSE BEGIN IF @Area != 0 AND @Room = 0 BEGIN INSERT INTO #tempTable (RowNum, LocationId, AreaId, RoomId) SELECT ROW_NUMBER() OVER (ORDER BY LocationId DESC) RowNum , LocationId , AreaId , RoomId FROM dbo.tblroomnew a SELECT @row_count = COUNT(1) FROM #tempTable END ELSE BEGIN EXEC dbo.proc_tblUserScheduleNewFutureUpdate @StartDatePassed , @EndDatePassed , @StartTimePassed , @EndTimePassed , @CurrentDateTime , @Scheduleid , @Contactid , @location , @Area , @Room , @ModifiedBy , @schedulefileidNew END END END </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload