Showing posts with label owner. Show all posts
Showing posts with label owner. Show all posts

Sunday, February 19, 2012

cross-database query from ASP.NET

How do you write a SQL SELECT statement for a cross-database query in ASP.NET (ADO.NET). I understand the server.database.owner.table structure, but the command runs under a connection. How do I run a query under two connections?You don't need 2 connections. Are your 2 databases on the same server?

If they are on the same server, the syntax would be like this:


SELECT
D1.column1,
D2.column2
FROM
database1.dbo.Table1 D1
INNER JOIN
database2.dbo.Table2 D2 ON D1.ID = D2.ForeignKey

If they are on different servers, the syntax would be like this:


SELECT
D1.column1,
D2.column2
FROM
Server1.database1.dbo.Table1 D1
INNER JOIN
Server2.database2.dbo.Table2 D2 ON D1.ID = D2.ForeignKey

You might encounter this error:Could not find server 'Server2' in sysservers. Execute sp_addlinkedserver to add the server to sysservers. which means that the system stored procedure sp_addlinkedserver would need to be run to allow access to Server2 from Server1. SeeSQL Server Link Server Performance Tips for some information pertaining to linked servers.

Terri

Thursday, February 16, 2012

Cross owner table replication

Hello,
We have a number of tables for which we need to setup a push type
replication. In the source db, the owner of those tables is dbo, but in the
subscriber dbs, all tables must belong to a different owner (our
application requirement). As I followed replication wizard, I could not
find any option to set it up this way (I got dbo owned tables in the
subscriber dbs).
TIA,
Vitaliy
When you get to the specify article dialog box, click on the browse button
to the right of the tables and in the general tab enter the name of the user
you wish to own the tables on the subscriber in the destination owner text
box.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Vitalik" <address@.domain.com> wrote in message
news:%23NbuNnu7FHA.4012@.TK2MSFTNGP14.phx.gbl...
> Hello,
> We have a number of tables for which we need to setup a push type
> replication. In the source db, the owner of those tables is dbo, but in
> the
> subscriber dbs, all tables must belong to a different owner (our
> application requirement). As I followed replication wizard, I could not
> find any option to set it up this way (I got dbo owned tables in the
> subscriber dbs).
> TIA,
> Vitaliy
>

Tuesday, February 14, 2012

cross database queries

i know that db.owner.tablename works in the query analyzer, but what i really appreciate from anyone is how to apply this in vb6 code since the recordset is opened only from one db using the following syntax:

rs.open "select ...", dbname, ..., adopendynamic, adlockoptimistic ...

thanksWrite a stored procedure. :)