Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have a table

Table1(UserID,ModuleID,SubModuleID,Status)

UserID ModuleID SubModuleID Status
-----------------------------------------
1 m1 sm1 False
1 m1 sm2 True

and I have a procedure

SQL
ALTER Proc [dbo].[sp_ModuleAccess]  
(
@UserId nvarchar(50)=null,
@Module nvarchar(50)=null,
@SubModule nvarchar(50),
@Status bit=null,
@Mode char(1)=null
)
AS
declare @moduleID table
(
  idx smallint Primary Key IDENTITY(1,1)
    , moduleid nvarchar(50)
)
declare @SubmoduleID table
(
  idx smallint Primary Key IDENTITY(1,1),
 moduleid nvarchar(50),
submoduleid nvarchar(50),
status bit
)
Begin
if @Mode='U'
Begin 
  if exists(select 1 from Table1 where UserID=@UserId)
  begin
     update Table1  set Status=@Status 
     where UserID=@UserId and ModuleID=@Module and SubModuleID=@SubModule 
  end          
       
end
END


Now I have two check box for sub module and a button so I want to know how to update both submoduleid behalf of check box
Posted
Comments
OriginalGriff 12-Nov-14 6:10am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps a "before and after" example of your data might help?
Use the "Improve question" widget to edit your question and provide better information.
Tomas Takac 12-Nov-14 6:20am    
Totally not clear. Why are you referring to buttons and checkboxes but only showing the stored proc? What are the @moduleID and @SubmoduleID table variables for?

1 solution

An UPDATE command will update all the records the WHERE clause defines - no where clause means update all the rows. However with a single UPDATE command you can change the rows only with the same value (all rows will get Status 0!). If you want to update different rows with different values you MUST have multiply UPDATE commands!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900