Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 SQL Server:Call one stored procedure from another?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Podge
Support Moderator

Ireland
3775 Posts

Posted - 15 December 2004 :  18:17:43  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
I have a simple stored procedure "sp1" on database1 which returns a value.

While connected to database2 I would like to execute sp1 on database1.

How can I do this? Is there a way to make sp1 available to one or more other databases?

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.

Edited by - ruirib on 15 December 2004 18:28:52

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 15 December 2004 :  18:34:04  Show Profile  Send ruirib a Yahoo! Message
You just need to fully qualify the stored procedure name: Database1.owner.sp1
Tipically owner is dbo and that being the case it would be: database1.dbo.sp1

Other than this there is no difference to execute a local stored proc.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 15 December 2004 :  18:39:24  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Excellent. Worked first time.

Thanks ruirib.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 15 December 2004 :  19:09:37  Show Profile  Send ruirib a Yahoo! Message
You're welcome.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 16 December 2004 :  05:26:26  Show Profile  Send pdrg a Yahoo! Message
Just a fyi - UDF's (User-defined-functions) can be used similarly, and can do some stuff you just can't do nicely with a sproc - for instance a recordset-returning sproc cannot be treated as a tabel in another sproc, but a table-returning UDF can. Sweet :)
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 16 December 2004 :  07:15:33  Show Profile  Visit D3mon's Homepage
quote:
Originally posted by ruirib

You just need to fully qualify the stored procedure name: Database1.owner.sp1
Tipically owner is dbo and that being the case it would be: database1.dbo.sp1

Other than this there is no difference to execute a local stored proc.



Nice! I had been wondering about that one for a while now.


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.37 seconds. Powered By: Snitz Forums 2000 Version 3.4.07