SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SP calls another SP
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 09/01/2007 :  09:06:02  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
can i , when 1 Stored Procedure 1 (sp1) calls to SP2
then in sp2 to know the name of the SP that called it,
withoguht the needto pass the calling name SP to SP2


thnak in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

Kristen
Test

United Kingdom
22403 Posts

Posted - 09/01/2007 :  09:32:35  Show Profile  Reply with Quote
Can't think of a way, other than possibly interrogating the SPID in some way ... which, if possible, would probably be a ghastly hack!

Kristen
Go to Top of Page

jen
Flowing Fount of Yak Knowledge

Sweden
4110 Posts

Posted - 09/03/2007 :  16:52:47  Show Profile  Send jen a Yahoo! Message  Reply with Quote
why make life more difficult? is this part of some sort of audit? Or are you going to use it as a condition inside sp2? just pass the name over to sp2

keep it simple.

--------------------
keeping it simple...
Go to Top of Page

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 09/07/2007 :  10:49:33  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
k

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

Page47
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 09/07/2007 :  10:58:54  Show Profile  Reply with Quote
Throwing good money after bad ....

Create a temp table in sp1:
create table #WhosYourDaddy(procname sysname)
insert into #WhosYourDaddy select 'sp1'

 
Then query that temp table in sp2, since it should still be in scope ...

Jay
to here knows when

Edited by - Page47 on 09/07/2007 10:59:20
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11750 Posts

Posted - 09/07/2007 :  11:04:22  Show Profile  Visit spirit1's Homepage  Reply with Quote
best way to go with this is
for your sp2 to have a parameter
@calledBy int

then you can call your sp2 like this
exec sp2 <yourParams>, @calledBy = @@PROCID


@@PROCID is the id of the current module (can be used in stored procedure, trigger or user defined function)

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp

Edited by - spirit1 on 09/07/2007 11:04:44
Go to Top of Page

jen
Flowing Fount of Yak Knowledge

Sweden
4110 Posts

Posted - 09/07/2007 :  13:43:58  Show Profile  Send jen a Yahoo! Message  Reply with Quote
excellent! that's very very nice indeed Mladen

--------------------
keeping it simple...
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11750 Posts

Posted - 09/07/2007 :  13:47:16  Show Profile  Visit spirit1's Homepage  Reply with Quote
i know

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 09/07/2007 :  14:35:02  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
nice
from which tables can i get data of : @@PROCID


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11750 Posts

Posted - 09/07/2007 :  14:37:26  Show Profile  Visit spirit1's Homepage  Reply with Quote
@@PROCID is a global variable
select @@PROCID

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 09/07/2007 :  14:44:06  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
ok

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000