TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
saich
NA
37
4.1k
stored procedure to update data in multiple tables
Dec 1 2016 1:20 PM
Hi,
I am new to sql. I am practicing on foreign key relationships by doing a small application. It have 3 tables. One table named
stpersonal
with cloumns as
stID, stname, stdateofbirth, stgender
. stID column is identity column and primary key column. As the student contain multiple fields in education, i used second table named
steducation
with fields
stID, stcollege, stgradyear
.
stID in steducation table has foreign key relation with stID in stpersonal table.
And third table
staddress
for student addresses with columns
stID, stAddress
.
stID in staddress table has foreign key relation with stID in stpersonal table.
I got the stored procedure to get all student details and delete and insert. But I a unable to figure out stored procedure for update. I tried the following method to create stored procedure
`create procedure stupdate
(
@ID int,
@stname nvarchar(50),
@stdateofbirth nvarchar(50),
@stgender nvarchar(50),
@stcollege nvarchar(50),
@stgradyear datetime,
@stAddress nvarchar(50)
)
as begin
update stpersonal
set
stname = @stname,
stdateofbirth = @stdateofbirth,
stgender = @stgender,
stcollege = @stcollege,
stgradyear = @stgradyear,
stAddress = @stAddress
where stpersonal.stID = @ID
end ` This is the code I tried. I tried to use joins, but nothing worked out. So i hope I could overcome this.
Thanks in advance
Reply
Answers (
2
)
How to make Relations for Instructor Schedule(1-n or n-m)
how to set auto fit in excel in sql