Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

database - database connection

hi,
does anyone know if it is possible to connect to one database from a stored
procedure another database? i was wondering if it would be possible to check
referential integrity between 2 tables in 2 different databases...
thanks,
sql newbie
[272 byte] By [sql newbie] at [2007-11-9 21:09:08]
# 1 Re: database - database connection
Yes, it is. But this is RDBMS specific. Which RDBMS are you using? Also,
are they on the same server?

"sql newbie" <niranjanv.NOSPAM@rocketmail.com> wrote:
>
>hi,
>
>does anyone know if it is possible to connect to one database from a stored
>procedure another database? i was wondering if it would be possible to check
>referential integrity between 2 tables in 2 different databases...
>
>thanks,
>sql newbie
>
MarkN at 2007-11-11 23:54:24 >
# 2 Re: database - database connection
hi,

thanks for ur response. i'm using MS SQL Server 2000 and both databases are
created in SQL Server and stored in the same location.

we're trying to integrate 2 applications - one a 'main app' and the other
an 'optional module' and were wondering if we could use 2 databases to keep
these two apps separate or if we had to use the same database for both apps...

thanks,
sql newbie

"MarkN" <m@n.com> wrote:
>
>Yes, it is. But this is RDBMS specific. Which RDBMS are you using? Also,
>are they on the same server?
>
>
sql newbie at 2007-11-11 23:55:18 >
# 3 Re: database - database connection
you can definitely keep them separate if you want, but if you want the data
easily backup together to easily maintain data integrity (in your backups)
between the 2 apps, then you should keep them in the same database. You
also cannot have (declarative) referential integrity across databases so you
would need to write triggers if you wanted to maintain referential integrity
across the 2 databases. If none of that deters you, then my recommendation
would be for the 'main app' to use a set of views to refer to the tables in
the 'opt mod'.

i.e. if you have a table on a database called "optmod" table called
"option1", then
CREATE VIEW dbo.vw_option1
AS
SELECT *
FROM optmod.dbo.option1
GO
and users in the 'main app' would have to be users in the opt mod app
database as well.
--
HTH,
David Satz
Principal Web Engineer
Hyperion Solutions
{ SQL Server 2000 SP2/6.5 SP5a } { Cold Fusion 5 SP1 } { VSS }
(Please reply to group only - emails answered rarely)
--------------------
"sql newbie" <niranjanv.NOSPAM@rocketmail.com> wrote in message
news:3d2c6610$1@10.1.10.29...
>
> hi,
>
> thanks for ur response. i'm using MS SQL Server 2000 and both databases
are
> created in SQL Server and stored in the same location.
>
> we're trying to integrate 2 applications - one a 'main app' and the other
> an 'optional module' and were wondering if we could use 2 databases to
keep
> these two apps separate or if we had to use the same database for both
apps...
>
> thanks,
> sql newbie
>
>
> "MarkN" <m@n.com> wrote:
> >
> >Yes, it is. But this is RDBMS specific. Which RDBMS are you using?
Also,
> >are they on the same server?
> >
> >
>
David Satz at 2007-11-11 23:56:19 >