How Do I Write SQL Query Accessing Multiple Databases (DBFs)?

Aug 8, 2006

I have several database files, all in the same directory. I want to write SQL statements that access two databases at once. For example, if only one database would be involved, I would write:


SELECT     Test_Source_ID_column, Data_column
INTO            Test_Destination_table
FROM         Test_Sources_table
The above query copies two columns (Test_Source_ID_column and Data_column) from Test_Sources_table into a brand new table called Test_Destination_table.
Now the above query is fine for both the old and new tables being in the same database. But what if Test_Sources_table is in file Old.dbf and I want the new table Test_Destination_table to be in New.dbf?
Both Old.dbf and New.dbf are in the same directory. Therefore, there is no security issue about using ......etcpasswords. I should therefore be able to use relative paths. So, I also want to know how I can do that select on two databases in the same directory without typing long, long paths.
Is there a way to do queries that access multiple database files (all database files being in the exact same directory) AND use relative paths or no paths (and certainly not type a full path)?
NOTE 1: I'm using SQLEXPRESS, therefore do not have the SQL Server 2005 tools. I have Visual Studio 2005 Developer Edition with its tools.
 NOTE 2: One table is accessed through ODBC. The other table is accessed through SQLEXPRESS.
 

View 5 Replies


ADVERTISEMENT

How To Write An Sql Across Multiple Databases

Dec 23, 2005

so, I am trying to write an sql that requires information across two
different database. It's under the same sql server. However, the
location of the tables are from different database.

Any links I can read about that can show me how to write the queries?

Thanks in advance, and merry X'mas.

View 1 Replies View Related

Issues About One Application Remotely Accessing Multiple Databases

Nov 22, 2007



Hello,

My next project(in VB.NET 2005) would involve accessing different DBs and tables in remote SQL servers

What are the steps that need to consider first? Are there any settings that needs to be done in the servers?
k

View 1 Replies View Related

Accessing Multiple Databases From Stored Procedure In SQL 2000

May 16, 2006

Hi ,

I have around 5 databases with same structure used to store data for different locations and services.

I have created an intermediate database which will have all the stored procedures to access data from above 5 databases.

My queries are common to all the databases. so,I would like to pass database name as an argument to my stored proc and execure query on specified database.

I tried this doing using "USE Databasename " Command. but it says ...We can not use "USE command " in stored proc or triggers. so ..what i did is ..

--------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE TestDB_access(@dbname varchar(100))
AS

BEGIN

DECLARE @localDB varchar(100)

Set @LocalDB=@dbname

if @LocalDB='XYZ'

EXEC ('USE XYZ ')
elseif @LocalDB='ABC'

EXEC ('USE ABC')


Select * from Mytable

END

---------------------------------------------------------------------------------------------------------------

When I run this from my database , it gives me an error "unable to find table "mytable".

What is the best way to make my queries work with all the databases.

Thanks in advance

Venu Yankarla

View 4 Replies View Related

Integration Services :: Schema Separation - Accessing Multiple Databases

Nov 8, 2015

We have a system that uses 3 databases, one for Membership db standard MS membership only the application has access to that data, one with User Data which we would like to make multi-tenant using Schema-Separation, and a third read-only reference db which is Common Market data for all users.we anticipate Tenant numbers in the thousands.Current we have multiple queries which create joins between the Main db and the Reference database using something like

Selec S.*, M.ScheduleDate, M.substation from Sites S left outer join Market.dbo.MarketUnit M where S.MarketUnitID = M.MarketUnitID

i'm planning to have a new schema for each Tenant on the Main Database, so I would create a Schema T1 for the first customer, a user T1User with access to T1 schema.  and grant T1User access to Market.dbo. My First question is are there any concerns about the above T1User setup? My second question is, are there any tools which would automate the setup of the multi-tenant with schema separation, or should I just script the whole Main Database schema creation and replace schema name globally and then execute the script?

My Third question, how about upgrade and updates... currently using VS to compare dev/qa/prod database to identify changed which need to be promoted, and pushing updates...  this could be a big pain to promote code to thousands of Schemas.  grantedwe will likely keep the overall number of schemas spread over different SQL servers.

View 2 Replies View Related

How Do I Write An Update Query Across 2 Databases.

Jan 4, 2008

I would like to write a query that will join two tables in separate databases (same server). Then update a field in one table using data and criteria from the other.

Its easy to do this in Microsoft Access by linking the tables using ODBC, but I found its not so simple to do directly in SQL Server

Thanks.





View 2 Replies View Related

Run Sql Query On Multiple Databases

Feb 5, 2007

I need to run a same query on 15 different databases and union the results.

Does any of the experts know how to do this with good performance?

Any help is appreciated.

Phil....the only reason i posted in T-Sql is because i will be using this query in reporting services :)

Thanks

View 9 Replies View Related

Multiple Databases Access In Query ... HELP ?

Jul 30, 1998

I try to fill a recordset with a query in an asp page to an SQL Server through ODBC connection :
The ODBC connection (eg : DB1Cnnection) is done to one Database (eg : DB1).
and I need to link to another Database (eg : DB2)

it `s like :
set rs=DB1Connection.Execute("Select DB1.xxx FROM TABLE1, TABLE2 WHERE ...")

Please, How do I `tell` to ODBC that TABLE2 is in DB2 ???
HELP !

View 2 Replies View Related

Select Query Form Multiple Databases

Dec 14, 2007

How do I write an sql statement to link tables in two databases and query them? For example: SELECT db1.table1.field1, db2.table1.field1 FROM Table1 INNER JOIN db1.table1.field1 ON db2.table1.field1 = db1.table1.field1
 
Thanks

View 6 Replies View Related

Accessing Two Databases

Sep 16, 2006

Hi, I am developing a small asp.net  application where I read from a readonly omnis database via odbc then dependant on user input write records to a second database.My first idea was to use an odbc connection to Omnis database and write to ms sql database.  There is quite a few queries that need to be made to the Omnis database and I am binding a datagrid to the MS Sql server database.  I was hoping to use stored procedures to update the mssql tables.  So there will be much opening and closing of connections. Should I go down that road or should i think of using an Access database, with linked table to the Omnis database, then only one connection needs to be made.  And I can store my information in the Access database tables. Thanks.

View 3 Replies View Related

Accessing Two Databases At Once

Apr 12, 2006

I'm new to databases as you probably can tell. A friend sent me three data bases, which in my mind should have been one database with all the tables included, but he didn't. So my question is, can you pull info from two databases in the same query?

I write the query acessing one database and the result chart must depend on a where predicate based on accessing tables in another database. If this isn't possible, how do I get the tables I need together, that presently reside in differing databases?

Thanks for the help in advance.

Milfredo

View 8 Replies View Related

Accessing 2 Databases On The SQL Server Through ASP.net

Nov 30, 2006

Hi everyone,
First of all I'd like to say I'm new to the forums, and in fact new to ASP.net.
I've had a couple of applications running in VB.net for the last year or so that I now am looking to move on and into ASP.net (main reason is to do with implementation to remote sites in foreign countries).
I'm currently following through the "Working with data and ASP.net 2.0" walkthrough on this site, which I must say has been a great help.
 I'll start with the background stuff first
I have my main database on an SQL server.  I also have 2 other databases on there - Customer and Employee.   The reason for these are that they are shared amongst my VB applications and I kept them as seperate databases so that one database is all that needs to be administered and maintained, and these changes are then seen on both apps (takes away redundant data as well).
In my main database, main table, is a field called CustomerID.  This value relates to the CustomerID in the Customer table.  In my VB app all I do is have the user select a customer name, and then the customer ID value is copied to the CustomerID field of my main table when inserting / updating a row.  This is simply accomplished with 2 SQL connections and 2 dataAdapters.  I also use 2 dataSets - one for Customer, one for WorkRequests (the main database)...
I use ComponentOne stuff so that my grid will show the CustomerName instead of the CustomerID etc, and the same applies when I use my Employee database - I run many dataAdapters to this for things such as Account Manager, Technologist, Creator, UpdatedBy etc etc.
Now, I'm new to VS 2005 - my apps were created in VS 2003 and .net 1.1.    Can I easily re-create my apps in ASP.net?  My primary goal at the moment is to make sure I can load a row, and display the "lookup" values instead of the "integer" value.  As my tables are in seperate databases, I would like to know the best way of accomplishing this, if it is of course possible.
Help and advice much appriciated.
Kind Regards,
Luke
 

View 2 Replies View Related

Accessing 6.5 Databases From 7.0 Admin?

Apr 10, 2002

hello,

i have a simple question and i am not familiar with sql7.

is it possible to access a sql server 6.5 from the admintools installed with sql 7.0

thanks
klaus

View 2 Replies View Related

Accessing SQL Server Databases From Networked PC

Jul 23, 2005

Hello all. I have just built another PC (New PC)and have it connected to myOriginal PC via a LAN. I have my SQL Server 2000 installed on the OriginalPC. Both PCs use WinXP Pro OS. I believe I now have to install the ClientTools on the New PC but after that, how do I access the SQL Server that ison the Original PC. The SQL Server is setup with mixed (both WindowsAuthentication and SQL Server Authentication). Just how do I use the SQLQuery Analyzer that I just installed on the New PC to connect to andretreive data from the SQL Databases which are on the Original PC? Thanksin advance for any help, Jim.

View 1 Replies View Related

Error When Accessing Sample Databases

Sep 17, 2007

Hey, Everyone - I have downloaded two of the sample databases and get the following error when I attempt to open them:


Unable to open the physical file "c:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAAssets_Maintenance_log.ldf". Operating system error 2: "2(The system cannot find the file specified.)". (Microsoft SQL Server, Error: 5120)


So what am I doing wrong? The install of these sample databases is simple and straight-forward.

Thansk!

Regards,
Bob Mitchell

View 7 Replies View Related

Transaction Support Across Tasks Accessing Two Different Databases

Apr 7, 2008

I am trying to determine if it is possible to add transaction support for a SSIS package. Here are the basic tasks:

Read New/Updated records from SQL Server
Update changed records in Access
Insert new records into Access
Update new records in SQL Server with Access key assigned on insert in previous step
Reset dirty_flag

I would like to wrap a transaction around this. If the package fails in the task that updates sql server with the Access key, the next time it runs, it duplicates the new records in Access because it did not finish the process. Is it possible to have a transaction wrap this entire process so I can undo the inserts to Access if I fail any subsequent tasks?

Thanks,

Steve

View 1 Replies View Related

Synchronizing Foxpro .DBFs Data With SQL Server Tables (realtime)????

Mar 16, 2008



Is it possible to use SSIS to synchronize the data between a Foxpro .dbf and a compatible SQL Server table on a near realtime basis?

I have succesfully created an SSIS package that will insert data into the SQL Server Table but this is only useful for migrating data. What I need is a way to insure that the data in the SQL Server table matches that in the .dbf on a near realtime basis.

Or is there a way to link from SQL Server to the .dbf (similar to an Oracle DBLink).

Thanks for any and all assistance.....

Dave

View 9 Replies View Related

Linking Tables From Different Databases Or Querying From Multiple Databases

Dec 10, 2007

Dear Readers,Is it possible, like in Access, to link to tables in other SQL databases that are on the same server? I have a query that I originally had in Access that queered from multiply databases. It did this by having those other tables in the other databases linked to the database that had the query. 
 

View 3 Replies View Related

Performances In SqlExpress 2005 When Accessing Multiples Databases

Apr 11, 2007

Hello,



I've written this stored proc, which have to collect records in one table in several databases. These tables contains very few records (1 to 10 max). In SQL Server standard edition, this stored proc is executed instantaneously. But in the Express, it could take 1 minute.



Is there a solution to this problem ?



Thanks in advance,



Best regards,



Guy



ALTER procedure [dbo].[SP_CHECK_USERS]

AS



select 'FIDUCIAIRE' as code,moment,nom,machine from MERCATORFIDUCIAIRE.dbo.sessions s1 where (s1.inactif=0) and (s1.nom<>'MercatorIshop')

union select 'TEST1 ' as code,moment,nom,machine from MERCATORTEST1.dbo.sessions s2 where (s2.inactif=0) and (s2.nom<>'MercatorIshop')

union select 'TEST10 ' as code,moment,nom,machine from MERCATORTEST10.dbo.sessions s3 where (s3.inactif=0) and (s3.nom<>'MercatorIshop')

union select 'TEST11 ' as code,moment,nom,machine from MERCATORTEST11.dbo.sessions s4 where (s4.inactif=0) and (s4.nom<>'MercatorIshop')

union select 'TEST12 ' as code,moment,nom,machine from MERCATORTEST12.dbo.sessions s5 where (s5.inactif=0) and (s5.nom<>'MercatorIshop')

union select 'TEST13 ' as code,moment,nom,machine from MERCATORTEST13.dbo.sessions s6 where (s6.inactif=0) and (s6.nom<>'MercatorIshop')

union select 'TEST14 ' as code,moment,nom,machine from MERCATORTEST14.dbo.sessions s7 where (s7.inactif=0) and (s7.nom<>'MercatorIshop')

union select 'TEST15 ' as code,moment,nom,machine from MERCATORTEST15.dbo.sessions s8 where (s8.inactif=0) and (s8.nom<>'MercatorIshop')

union select 'TEST16 ' as code,moment,nom,machine from MERCATORTEST16.dbo.sessions s9 where (s9.inactif=0) and (s9.nom<>'MercatorIshop')

union select 'TEST17 ' as code,moment,nom,machine from MERCATORTEST17.dbo.sessions s10 where (s10.inactif=0) and (s10.nom<>'MercatorIshop')

union select 'TEST18 ' as code,moment,nom,machine from MERCATORTEST18.dbo.sessions s11 where (s11.inactif=0) and (s11.nom<>'MercatorIshop')

union select 'TEST2 ' as code,moment,nom,machine from MERCATORTEST2.dbo.sessions s12 where (s12.inactif=0) and (s12.nom<>'MercatorIshop')

union select 'TEST20 ' as code,moment,nom,machine from MERCATORTEST20.dbo.sessions s13 where (s13.inactif=0) and (s13.nom<>'MercatorIshop')

union select 'TEST21 ' as code,moment,nom,machine from MERCATORTEST21.dbo.sessions s14 where (s14.inactif=0) and (s14.nom<>'MercatorIshop')

union select 'TEST23 ' as code,moment,nom,machine from MERCATORTEST23.dbo.sessions s15 where (s15.inactif=0) and (s15.nom<>'MercatorIshop')

union select 'TEST3 ' as code,moment,nom,machine from MERCATORTEST3.dbo.sessions s16 where (s16.inactif=0) and (s16.nom<>'MercatorIshop')

union select 'TEST4 ' as code,moment,nom,machine from MERCATORTEST4.dbo.sessions s17 where (s17.inactif=0) and (s17.nom<>'MercatorIshop')

union select 'TEST5 ' as code,moment,nom,machine from MERCATORTEST5.dbo.sessions s18 where (s18.inactif=0) and (s18.nom<>'MercatorIshop')

union select 'TEST6 ' as code,moment,nom,machine from MERCATORTEST6.dbo.sessions s19 where (s19.inactif=0) and (s19.nom<>'MercatorIshop')

union select 'TEST7 ' as code,moment,nom,machine from MERCATORTEST7.dbo.sessions s20 where (s20.inactif=0) and (s20.nom<>'MercatorIshop')

union select 'TEST8 ' as code,moment,nom,machine from MERCATORTEST8.dbo.sessions s21 where (s21.inactif=0) and (s21.nom<>'MercatorIshop')

union select 'TEST9 ' as code,moment,nom,machine from MERCATORTEST9.dbo.sessions s22 where (s22.inactif=0) and (s22.nom<>'MercatorIshop')

View 2 Replies View Related

Accessing SQL Mobile Databases In VB2005 - Pocket PCApp

Mar 1, 2006

I am using VS 2005 to develop a Pocket PC 2003 application and for some reason I dont have the ability to assign my datasource to a SQL Mobile Database?

When opening Server Explorer, right clicking Data Connection, Add New Data Source, Change Data Source, the only options I get are

Microsoft Access Database File
Microsoft ODBC Data Source
Microsoft SQL Server
Microsoft SQL Server Database File
Oracle Database
<other>

I was trying to follow the tutorial



Step by Step: Developing a SQL Mobile Application with Visual Studio 2005
and SQL Server 2005 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/med302_msdn_sql_mobile.asp)
and in that tutorial when they do the exact same thing it shows a screen shot that also lists 'Microsoft SQL Server Mobile Edition'

Any ideas why I dont have that option? FYI, I have SQL Server 2005 and have installed SQL Server 2005 Mobile Edition.

Thanks

Mike

View 5 Replies View Related

Accessing Mobile SQL Databases In VB2005 - Windows Apps

Dec 9, 2005

I have both used the Data Connection Wizard and tried programatically to

View 29 Replies View Related

Denormalization, 2 Databases , 1 Read 1 Write Db

May 28, 2008

Hi,
I was reading that many of these high traffic websites actually have 2 databases, 1 database is used ONLY for reads, while the other is for writes.

How does one go about creating such a setup? How does the database where writes are allowed replicated the data to the read only database server?

View 1 Replies View Related

How To Prevent Domain Admin Users From Accessing SQL 2000 Databases?

Mar 6, 2008

Based on our database infrastructure, we need to secure our SQL databases. The security issue concerns on allowing a limited number of Domain Admin users to access the SQL databases.
We tried certain ways, based on the documents in the Microsoft web site, but we couldn€™t reach to the point of preventing the Domain Admin users accessing the SQL databases.

Thanks in advance.

View 5 Replies View Related

Transact SQL :: Create Email Report Which Gives Result Of Multiple Results From Multiple Databases In Table Format

Jul 24, 2015

I'm trying to create an email report which gives a result of multiple results from multiple databases in a table format bt I'm trying to find out if there is a simple format I can use.Here is what I've done so far but I'm having troble getting into html and also with the database column:

EXEC msdb.dbo.sp_send_dbmail
@subject
= 'Job Summary', 
@profile_name  =
'SQL SMTP',
   
[code]....

View 3 Replies View Related

Creating A Database From Multiple Databases Accross Multiple Servers

Sep 13, 2007

Hi,

I'm trying to create a database that takes specific information from a number of databases on different servers to make some reporting that we have much easier.

I'm pretty new to SQL so I'm not sure of the best way to proceed. I read an article that suggested I use the OPENROWSET command. The problem is, the version of SQL that came with one of the programmes we use is limited and will not allow you to turn on the allow "Ad Hoc distributed Queries" so the SLQ statement will not execute.

I'm confused why it won't let me to connect through ODBC as I've created a web page that selects data from this database with no problems!

Here is the SQL statement that I've written to make sure it is the correct one (on the msdn library page it said that this was the ODBC connection):

SELECT a.*
FROM OPENROWSET('MSDASQL','DRIVER=(SQL Server);SERVER=APPOLOACT7;UID=sa;PWD=***************',
'SELECT * FROM MDCTestAndDev.dbo.TBL_CONTACT') AS a



I've also created the ODBC connection using the tool on Administration Tools>Data Sources ODBC

Any help would be greatly appreciated (also any ways of selecting from one database and inserting it into another will be helpfull)

Thanks

View 8 Replies View Related

Merging Data From Multiple Databases With Multiple Tables (all With The Same Structure)

Nov 15, 2006

Hi!

I have 7 source databases and one target database, all using the same structure. The structure is made of 10 tables, with foreign key constraints.

I need to merge the source databases into the target (which won't have any data before that process, but will already have the correct schema), and to keep the relationships between the records.

I know how to iterate over the source databases (with SMO foreach), but I'd like to know if someone can advise the best copy method for that context in SSIS ? (I don't want to keep the primary keys, but I need to keep the relationships...)

Any pointer most welcome!

best regards and thanks

Thibaut

View 1 Replies View Related

SQL Tools :: How To Restore Multiple Databases From Multiple BAK Files At Once

Aug 14, 2012

I am trying to restore multiple .bak backup SQL database files onto a new server. However, I have found that it will not allow me to restore multiple databases at once. Is there a way to do this so that I do not have to manually upload one at a time? I tried adding all the .bak files at once to the backup device window but it only did the first one listed. It would be so much easier to restore them all at once so that I do not have to continue this manual process. I am restoring them via device.

View 13 Replies View Related

JOIN Multiple Tables From Multiple Databases

May 23, 2008

Hello,
I am in the progress of designing a new section of my database and was thinking of creating a hole new database instead of just creating tables inside the database.  My question is can you JOIN multiple tables in an SQL Statement from multiple databases.  Ie, In the Management program I have a database called 'Convention' and another one called 'Services', inside the two databases there are many tables.  Can I link say tblRegister from Convention to tblUser in Services?
Thanks

View 3 Replies View Related

Accessing The Same Database Using Multiple Threads

Aug 22, 2007



hi,

do i need to use specially synchronized code if i have multiple threads inserting, updating and reading rows to and from the same database?? in this case, i know that no 2 threads will try to insert or update the exact same row into the DB, however, multiple threads might try to read the same row from the database.

thanks!

View 3 Replies View Related

Accessing One Database From Multiple SQL Servers

Dec 1, 2006

Apologies if this question has been asked before. I am about to upgrade a multiuser application based on Access97 and VB6 to C# and possibly SQL Server Express.

My customer does not want to use a server based database solution ie a single instance of SQL Server, but prefers to have a common networked dataset which is accessed via user's own individual database engines. This is because of restrictions on the installation of server based apps.

Does this scenario completely rule out the use of SQL Server Express?

Thanks

View 3 Replies View Related

How Do You Write Multiple DELETES In Same SP

May 23, 2007

I want to use one stored procedure to delete rows in three different tables - how do I write this for Sql Server 2000 please?
PROCEDURE dbo.DeleteSubmission  @C_ID intASDELETE *FROM tblCompaniesWHERE C_ID = @C_ID
DELETE *FROM tblStoresWHERE CS_ID = @C_ID
DELETE *FROM tblDistributorsWHERE CD_ID = @C_ID
RETURN

View 4 Replies View Related

Syntax For Returning And Accessing Multiple Result Sets In MSSQL 2k

Dec 29, 2006

Seasons greetings to everyone,A simple question. Could someone show me the syntax to produce multiple (2 or 3) result sets in a stored proc and how you access those sets from a c# program (ASP.NET)..Couldn't find a reference on Google, maybe I was asking the wrong question! Thanks for any help regardsDavej 

View 3 Replies View Related

Database In Dropbox Sync Folder Accessing From Multiple Computers?

Nov 2, 2015

I currently use Access and have found that I need to migrate to SQL Server. I need setting it up.

Currently, I have multiple computers (home, office, laptop, etc.). On each of these computers, I have a folder which syncs via Dropbox. In this folder, I have my Access database which allows me to read/write to the Access database from any computer, and these changes are automatically synced to all the other computers via Dropbox.

I have installed the SQL Server database in the Dropbox folder then installed Management Studio on each computer. But only the computer which did the database install can link to the the SQL Server database. The other Management Studios cannot see the database.

Is there a way to achieve what I am after or is this a limitation of SQL Server? I do not want to have to manage a network or anything.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved