By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,364 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,364 IT Pros & Developers. It's quick & easy.

How to return a Pk value from one stored procedure to another stored procedure

P: 22
I have one stored procedure like sp_insertEmployee

Employee Table Fileds

Eno int pk,
ename varchar(100),
designation varchar

In stored Procedure After inserting the ename and designation it has to return the Eno pk Id automatically

I have another Department

deptno int pk,
Eno int fk,
Depname varchar

In this stored procedure I need to execute the sp_insertEmployee
Stored procedure and we need that Pk return value after executing that

By using that Id in this Department table we will insert the eno

can u help me out on this issue

Thanks
May 15 '08 #1
Share this Question
Share on Google+
2 Replies


Delerna
Expert 100+
P: 1,134
Stored proc 1 calls stored proc 2 and uses the results returned by stored proc 2


Make stored proc 2 a user defined function instead.
A user defined function can work like a stored proc and return a result to the calling stored proc
May 15 '08 #2

ck9663
Expert 2.5K+
P: 2,878
Make sure to handle error properly on your first proc/function.


-- CK
May 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.