Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 help with store procedure

Author  Topic 

ameya_amu
Starting Member

25 Posts

Posted - 2008-08-20 : 03:05:07
hello friends


i have 2 table table employee and employee_education.
i want to create storeprocedure. when i insert record in employee table i need on related
to that employee id(which is auto incremented) i need to insert four(number may vary) record in employee_education table
if any of the four record in the employee_education cannot be saved due to any problem then the whole transaction should be rollback.


can any one help me out . is storeprocedure is suitable or any other alternative.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-20 : 04:21:30
you can do this in a procedure. how will you decide values for four (or any number) of records for insertion? provide some sample data.
Go to Top of Page

ameya_amu
Starting Member

25 Posts

Posted - 2008-08-20 : 06:14:26
i have following tabel
1) Employee
with following fields
i) Emp_id (auto increment)(PK)
ii) Emp_name (nvarchar)

2) Employee_Education
with following fields
i) EE_ID (auto increment)(PK)
ii) Emp_id (FK)
iii) Degree (nvarchar)


i have following record in Employee table

1 A
2 B
3 C


i have following records in Employee_Education
1 1 M-Com
2 1 MCA
3 2 M-COM
4 2 MCAT




Go to Top of Page
   

- Advertisement -