Dotnet ReSource
Dotnet ReSource

Reputation: 201

how to insert data in particular column of table?

Hi i have table in database call Employees

       Employees
     ------------- 
    id|Name|Pwd|Isblocked
     1|anil|anil|

what i want to do is when user exceeds his logins attempts....based on username i should insert "yes" in the "isblocked " cloumn of Employees.....

i used this procedure but its insesting in a new row

   create procedure SP_IsBlocked
   (
   @IsBlocked varchar (50),

    )
     as 
   begin
   insert into PTS_Employee (Emp_IsBlocked) values (@IsBlocked) 
   end

can any one tell me how to write a query for this....

Upvotes: 0

Views: 344

Answers (4)

SoftwareNerd
SoftwareNerd

Reputation: 1895

t will be good if u use an update statement for it rather than insert.....

    create procedure SP_IsBlocked
     (
     @IsBlocked varchar (50),
     @EmployeeName varchar (50)
      )
     as 
     begin
    update tablename set Emp_IsBlocked=@IsBlocked where Emp_name=@EmployeeName  
     end

Upvotes: 1

Ovais Khatri
Ovais Khatri

Reputation: 3211

you can do like this:

 create procedure SP_IsBlocked
   (
   @IsBlocked varchar (50),
@Id int

    )
     as 
   begin
  update PTs_Employee
set IsBlocked = @IsBlocked
where id = @Id
   end

Upvotes: 1

slapthelownote
slapthelownote

Reputation: 4279

Perhaps something like:

create procedure SP_IsBlocked
(
@Employee_Id int,
@IsBlocked varchar (50)
)
as 
begin
 update PTS_Employee 
 set Emp_IsBlocked = @IsBlocked 
 where id = @Employee_Id
end

Upvotes: 1

Prabhavith
Prabhavith

Reputation: 476

U should use update command instead of insert as it inserts in a new row

Upvotes: 0

Related Questions