Groups | Blog | Home
all groups > sql server new users > october 2005 >

sql server new users : Stored Procedures across databases.


SQL
10/31/2005 5:02:58 AM
Yes this is possible
create proc in DB1
And the reference DB2 in you code like this
(DBName.ObjectOwner.ObjectName)
select * from DB2.dbo.table

------------------------------------------------------------------------------------------
"I sense many useless updates in you... Useless updates lead to
fragmentation... Fragmentation leads to downtime...Downtime leads to
suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG
and DBCC DBREINDEX are the force...May the force be with you" --
http://sqlservercode.blogspot.com/
SW
10/31/2005 12:17:35 PM
Hi,

Is it possible to create a stored procedure that will sit in one database
but perform a select statement on tables existing in another database?
I can't put the stored procedure in the same database!

Thanks

SW

SW
11/2/2005 10:01:47 AM
[quoted text, click to view]
HI,

I tried the following SP but it returns an error when I call it from my vb6
app. The error is Invalid Object Name 'Sport.dbo.Document'
The database that the sp is based in is called GSP, the database that it's
trying to look at is called Sport.

CREATE PROCEDURE [dbo].[spGetDocument] AS
Select Distinct DocNum From Sport.dbo.Document Where Live = 1 And Date >=
'10/23/2005'

GO

Thanks for your help,

SW

AddThis Social Bookmark Button