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 2008 Forums
 Transact-SQL (2008)
 share sp/udf/tr across several Identical databases
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

fan2005
Yak Posting Veteran

84 Posts

Posted - 11/02/2013 :  03:17:49  Show Profile  Reply with Quote
Hi,
I need to know how a sp/udf can be shared across several Identical databases in same sever instance.
SPs use tables ,global temptable using ## .
and a solustion to call sp /udf and all issues with trigers
Or I can even think about a solusion ( API or any command) to create / replcace sp/udf whith a neet solution in all DBs.

thanks for your reply.

Edited by - fan2005 on 11/02/2013 03:18:18

James K
Flowing Fount of Yak Knowledge

3653 Posts

Posted - 11/02/2013 :  09:27:05  Show Profile  Reply with Quote
There is no facility in SQL Server that allows you to create a "global stored procedure" that has scope at the server level. A stored procedure belongs to a database.

It is possible to access the stored procedure in one database from another database using the 3-part naming convention - the syntax is datbasename.schemaname.storedprocedurename. But even so, the stored procedure belongs to the database where it is created.

You can create identical stored procedures in all databases - run the script on each database.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 11/02/2013 :  13:14:58  Show Profile  Reply with Quote
are you asking about replication? if yes stored procedures can be replicated across databases.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

fan2005
Yak Posting Veteran

84 Posts

Posted - 11/03/2013 :  08:25:09  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

are you asking about replication? if yes stored procedures can be replicated across databases.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




Is it Possible to just replicate sps and functions from one db to another. For example form operational db to test db
again from operational db to another db (weeklydb) ,....
where in test db we may have old version of the same sp.

Thank you for your reply.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 11/03/2013 :  09:16:35  Show Profile  Reply with Quote
quote:
Originally posted by fan2005

quote:
Originally posted by visakh16

are you asking about replication? if yes stored procedures can be replicated across databases.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




Is it Possible to just replicate sps and functions from one db to another. For example form operational db to test db
again from operational db to another db (weeklydb) ,....
where in test db we may have old version of the same sp.

Thank you for your reply.



its possible to replicate it across dbs. But multiple versions of same sp cant coexist in any dbs. the latest version will overwrite existing one.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

ScottPletcher
Constraint Violating Yak Guru

USA
374 Posts

Posted - 11/04/2013 :  15:52:28  Show Profile  Reply with Quote
For stored procedures, you can create a stored proc in the master db, with the name beginning with "sp_", mark it as a system object, and have it run in the context of any db from which it is called.

I've never found any way to do that kind of thing for a function.
Go to Top of Page

fan2005
Yak Posting Veteran

84 Posts

Posted - 11/05/2013 :  14:56:08  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

quote:
Originally posted by fan2005

quote:
Originally posted by visakh16

are you asking about replication? if yes stored procedures can be replicated across databases.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




Is it Possible to just replicate sps and functions from one db to another. For example form operational db to test db
again from operational db to another db (weeklydb) ,....
where in test db we may have old version of the same sp.

Thank you for your reply.



its possible to replicate it across dbs. But multiple versions of same sp cant coexist in any dbs. the latest version will overwrite existing one.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




What about sps that are created after setting replication are they transfered to second server?

Edited by - fan2005 on 11/05/2013 14:56:56
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.08 seconds. Powered By: Snitz Forums 2000