Store Procedure to update

  • How can i write a store procedure in sql server to update a particular row of a table.

    For Example i have a table name Emplyee which have column empid ,name ,salary. Now the data are as

    empid name salary

    1 a 1000

    2 b 2000

    so how can i update the row of empid of 2

  • Example:

    create procedure spEmployeeUpdate

    (

    @EmpId integer,

    @Name char(75),

    @Salary decimal(8, 2)

    )

    as

    update employee set [name] = @Name, Salary = @Salary where empid = @EmpId

  • thanks if the empid is automatically generated no then is it same

  • Yes.

  • thanks now if i have another table name empadd where i have to update at the same time and whose fields are

    EaddID address empid

    1 abc 1

    2 asd 2

    then what will be the change

    here empid of empadd is foreign key of the table emplyee

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply