Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Store Procedure to update Expand / Collapse
Author
Message
Posted Wednesday, July 2, 2008 2:34 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 17, 2008 4:47 AM
Points: 15, Visits: 49
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
Post #527094
Posted Wednesday, July 2, 2008 4:12 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 4:17 AM
Points: 1,101, Visits: 5,279
Example:
create procedure spEmployeeUpdate
(
@EmpId integer,
@Name char(75),
@Salary decimal(8, 2)
)
as
update employee set [name] = @Name, Salary = @Salary where empid = @EmpId

Post #527133
Posted Wednesday, July 2, 2008 4:28 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 17, 2008 4:47 AM
Points: 15, Visits: 49
thanks if the empid is automatically generated no then is it same
Post #527142
Posted Wednesday, July 2, 2008 4:42 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 4:17 AM
Points: 1,101, Visits: 5,279
Yes.

Post #527148
Posted Wednesday, July 2, 2008 5:09 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 17, 2008 4:47 AM
Points: 15, Visits: 49
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
Post #527165
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse