Thanks for the tips. Let me try and give you a better idea.Here is my table.CREATE TABLE [dbo].[tblAvailability2]( [userID] [int] NOT NULL, [year] [int] NOT NULL, [day] [int] NOT NULL, [tag] [varchar](250) NULL, [availStatus] [tinyint] NULL, [sheetID] [int] NULL, CONSTRAINT [PK_tblAvailability2] PRIMARY KEY CLUSTERED ( [userID] ASC, [year] ASC, [day] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GO
Sample DataINSERT INTO tblAvailability2(sheetID, userID, day,year,availstatus,tag)SELECT 1, 5, 256,2009,3,nullSELECT 1, 6, 256,2009,3 ,nullSELECT 1, 7, 256,2009,3 ,nullselect 1, 8, 256,2009,3,null
Here is my SP.CREATE PROCEDURE [dbo].[updateActorAvailability] -- Add the parameters for the stored procedure here@listID int,@oldDay smallint,@oldYear smallint,@newWorkDay smallint,@newWorkYear smallint,@availStatus tinyintASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- change the availability date for that sheet UPDATE tblAvailability2 SET availStatus = @availStatus, [day] = @newDay,[year] = @newYear WHERE sheetID = @listID -- re-insert previous records for all users of that listID for oldDay and oldYear, and set thier status to 0 END
i hope this helps.