Connecting Tables From Different Databases

Apr 23, 2007

Hey everyone. I am somewhat of a newbie to the database world.
I have been given the task of connecting two different SQL databases. Both are Microsoft SQL.

I want some of the tables of one of the databases to be linked to the tables of the other.

Is this possible?


Thanks

RoadHired

View 1 Replies


ADVERTISEMENT

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

Connecting Two Different Databases

Jan 9, 2005

Hi,

Is there a way to connect to two separate databases at the same time through my web application?

In my web.config under the configuration/appSetting I have created two keys for database connection:
<add key="MyConn" value="server=PLMNBKPLMNBKSQLSERVER;uid=sa;pwd=xxxx;database=SourcingDB" />
<add key="MyConn2" value="server=PLMNBKPLMNBKSQLSERVER;uid=sa;pwd=xxxx;database=SeaTender" />

This enable me to pass the connection string to a session variable through a dropdownlist box and connect to the desired database.

However, I would like to create a dataset from two tables which are not in the same database, one in the "SourcingDB" and the other one in the "SeaTender".

Thanks for some guidance.

PLM

View 4 Replies View Related

Connecting To 2 Databases Inside One Query

Sep 16, 2004

hi there,
I saw a similar thread before but i've tried it and no luck. I want run a query off a database (stawebdata.branchinfo) then a join into bluepages.phonelist

i've tired

JOIN bluepages.phonelist p

Incorrect syntax near the keyword 'JOIN'.

any ideas... is this possible?

complete code below:

select DISTINCT b.name, b.tel1, b.id, b.telprivate,b.sc, b.manager,b.branchEmail
from branchInfo b
inner
JOIN bluepages.phonelist p on b.name = p.subdepartment
where b.name like 'Sarah' or b.id LIKE '%@keyword%' OR b.county LIKE '%@keyword%' OR b.Area LIKE '%@keyword%' OR b.Manager LIKE '%@keyword%' OR b.AssistantManager LIKE '%@keyword%' OR b.Postcode LIKE '%@keyword%' OR b.PseudoCity LIKE '%@keyword%' OR b.TicketingTA LIKE '%@keyword%' OR b.SLC LIKE '%@keyword%' OR b.ItineraryTA LIKE '%@keyword%' OR b.TIDS LIKE '%@keyword%' OR b.ABTA LIKE '%@keyword%' and
p.department = 'UK Branch' and
b.isbranch <> 'False' or
(p.lastName = '@keyword' or p.firstname = '@keyword')
order by b.name asc
GO

View 2 Replies View Related

Ways Of Connecting To Remote Databases

Mar 15, 2004

Hi everyone.

I need to know which are the best ways to connect to a remote SQL SERVER 2000 from inside a VB6 application. By remote I mean on a dedicated server outside my LAN that I can access by IP address.

Any opinion would be appreciated.

View 3 Replies View Related

Connecting To 2 Diffrent Sql Servers Databases From Single Web Application

Oct 31, 2007

i am having 2 sql servers one is web sql server  server and other server is my local sql server. i am making web application through which i want to connect both sql servers at a time and by selecting data from web server i want to insert it into my local sql server both having same database on which i want to work , i want to know how it can be done
my idea as follows in  web.config  i specify 2 connection string and by selecting data from  websql server database table i going to store it in dataset and then i return dataset to another function which connects to local sqlserver database.but database records are much large. can any body guide me .
i am going to place my web application on local server (C# asp.net 2.0) .
thank you,
 
i tried this code
c# file
 public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Uupdatedata();

}
public void Uupdatedata()
{
string constr1=ConfigurationSettings.AppSettings["abccon1"];
string constr2 = ConfigurationSettings.AppSettings["abccon2"];
System.Data.SqlClient.SqlConnection dbcon1 = new System.Data.SqlClient.SqlConnection(constr1);
dbcon1.Open();
System.Data.SqlClient.SqlConnection dbcon2 = new System.Data.SqlClient.SqlConnection(constr2);
dbcon2.Open();

SqlDataReader dr;
SqlCommand cmd = new SqlCommand("select * from Unit_Master",dbcon1);
dr = cmd.ExecuteReader();
while (dr.Read())
{
string Sql = "insert into Table1(Unit_Id,Unit_Desc) values(" + dr.GetInt32(0).ToString() + "," + dr.GetString(1) + ")";

SqlCommand cmd1=new SqlCommand (Sql,dbcon2);
//cmd1.EndExecuteNonQuery ();

}

//dr.Close();
//dbcon2.Close();
}
 web.config<configuration>
<appSettings>
<add key="abccon1" value="Data Source=comp01;Initial Catalog=abc;User Id=sa ; Password=sa"/>
<add key="abccon2" value="Data Source=comp01;Initial Catalog=abctest;User Id=sa ; Password=sa"/>
</appSettings>
<connectionStrings/>
 this 2 databases are from single my loacl server
it wont work it gives exception
please healp me.

View 4 Replies View Related

Problem In Connecting 2 Databases With Sql Server 2005 Express

Aug 23, 2006

I am programming in VB6 using ADO 2.8. This connection and query works in MS access, SQL server 2000 and Sql Server 2005. does not work in Sql server 2005 express. Any Suggestions?

Connection String #1 Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;AttachDBFileName=C:Program FilesMaterial_Management_SystemDATAMain.mdf;Data Source=Steve_Laptopsqlexpress

Connection String #2 Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;AttachDBFileName=C:Program FilesMaterial_Management_SystemDATAItems.mdf;Data Source=Steve_Laptopsqlexpress


Sql Query: Select POLINE.ID as POLine_ID, PFMS.ID as Items_ID FROM POLINE LEFT JOIN Items.PFMS as PFMS ON POLINE.lItem_ID = PFMS.ID

Error: Msg 208, Level 16, State 1, Line 1
Invalid object name 'Items.PFMS'

Sql Query#2: Select POLINE.ID as POLine_ID, PFMS.ID as Items_ID FROM POLINE LEFT JOIN Items.dbo.PFMS as PFMS ON POLINE.lItem_ID = PFMS.ID

Error: Msg 208, Level 16, State 1, Line 1
Invalid object name 'Items.dbo.PFMS'.

I am running the queries directly from the 2005 Mgt window to take as many variables out of the equasion. I get the same error in Visual basic

How am I supposed to reference a join of 2 databases? Any suggestions

View 1 Replies View Related

Error Connecting Database Problem After Moving Databases 2000 To 2005

Nov 9, 2007

I have moved my databases to 2000 to instance of 2005 on the same server.
Now i set databases offline in 2000 as i did upgrade use backup & recovery method.

& my connection string
Password=test;Persist Security Info=True;User ID=test;Initial Catalog=databasename;Data Source=ipaddress

i was using above connection string to connect when using 2000 databases form applications in the production machine

I get the following error when i am running my applications now after moving to 2005


An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

IS it because i have two server on one server or
What do i need to do in order to fix this....tried several thing by searching nothing worked out..

Let me know
thanks


View 9 Replies View Related

Connecting Tables

Mar 5, 2007

I have a table with columns Suppliers Name, Product and Quantities.
I also have another auxiliary table where I insert records(Supplier Name, Product and Quantities) from an external application. What I want is when I insert records in the second table the corresponding records of the main table to be updated and all the records in the auxiliary to be deleted.
Do I have to use stored procedures????

View 3 Replies View Related

Connecting Tables

Aug 18, 2007

Hey everyone,
I am beggining in SQL and the .NET framework and have been running into some problems trying to design a relational database. I am completely new to it so I bought a book that was recommended in this Forum called "Handbook of Relational Database Design" and it has been pretty usefull so far. RIght now I am trying to make the Logical Data Model before I make the Relational Data Model.
The problem that I am having right now is creating a table that is a derivation from another table. For example, in the book they have a table called Property, and then two other tables called MountainProperty and BeachProperty. MountainProperty and BeachProperty are a type (relationship here) of a property. So basically Property will hold some data in a table, and then MountainProperty and BeachProperty will extend that property to contain more specific data. This is very similar to what I want to do. However I am having a problem understanding how an instance (or row) in Property, will have a link (foreign key) to a piece of data that is in Mountain or BeachProperty. I understand the foreign key in Mountain and BeachProperty and how they will link back to their "parent". But how will Property know its children, where is the link for that, how can one make a link to that. You could make a column with a foreign key, but which table would it point to, can one column point to mulitple tables? That doesn't make very much sense to me.
Basically what I am trying to say is that a row in the Property table can be multiple types, and these types will store more additional data about that row. How can I link to that data from that row in the table Property.
The only way that I can think of to link to that table is by making another column called PropertyType where MountainProperty equal 1 and BeachProperty equals 2. So I would perfrom a query in my application on the row like "Select PropertyType from Property" which would give me back 1 or 2. Based upon that I would then know which table to search for in the database and would then perfrom another query on the specific table, either MountainProperty or BeachProperty.
I am terribly sorry if this is confusing or if it is so appartently easy for you, but this is the first time that I have ever tried to make a relational database and I am really struggling on seeing how to organize these tables properly. Thank yor for your time.
Jeremy

View 5 Replies View Related

Connecting SQL Tables To Access

Oct 11, 2007

I have been tinkering with connections to SQL Server 2000 from Access 2000 for a couple of days without much luck.

My most recent attempt is the following code to the click event of a command button on a form. Most of this code was acquired from other places on the net.

Dim oConn As ADODB.Connection

Set oConn = New ADODB.Connection
oConn.Open "Provider=sqloledb;" & _
"Data Source=Hed001;" & _
"Initial Catalog=My_Views;" & _
"User Id=;vel007" & _
"Password=driver"

Dim oRS As ADODB.Recordset
Set oRS = New ADODB.Recordset

oRS.Open "Select * from VOrder_Header", oConn


Amazingly, it does not error out. But what do I do next to see the records in VOrder_Header?

Just a newb blazing at trail here in the unknown...

View 1 Replies View Related

Totally Confused Connecting Two Tables?

Jan 30, 2008

 Hello everyone. I need some assistance here. I have a web form to get information about user details. The web form has two parts. the first part is user personal information  where there is few textboxes, dropdownlist , radiobuttons , checkbox etc. this is where user inputs his personal information. the second part contains the office information where there is few textboxes, dropdownlist , radiobuttons , checkbox etc too. but the second part is automatically populated by data from the database(lets say table1). this happens as soon as user selects an option from dropdownlist in second part(here an option for dropdownlist is name of the office) . there is also a save and cancel button at the end of the form.now what i want here is, whenever i click a save button in my webform,i want the data of first part of my webform (ie user personal information) to get stored in new table(say table2).but i dont want the data of secont part of my webform(ie office information) to get stored in table2.(coz its already stored in table1.thats from whereit got populated earlier).But i want a reference of second part of my web form(ie office info) in table2.(only the reference id of related data from table1.not the whole data)and finally i want to display data from both the tables in one single details view.(both personal and office information)i hope u people are gettin it?i know i have to use foriegn keys.but i dont know how to use in this case.(sql express)and can u plz explain how to implement this in cs file with example including source code.(c#, vwd2005 express, sql express). thanks. jack.     

View 5 Replies View Related

Many Databases Vs. Many Tables

Apr 14, 1999

Hi,
I'm writing an intranet application - a web survey engine.

I'd like to create a new database for each user that creates a survey form...
versus creating new tables for each survey.

Memory and disk space is not exactly the problem... just user permissions. If I dump all the results onto one database, doesn't it mean that this user can have access to all other tables(including the results of other surveys??)

Question is, does SQL Server reserve a bunch of memory for each database that I create, thereby hogging up a lot of space if I create more than one database.

Thank you.

View 1 Replies View Related

All Databases' Name With Their Tables' Name

Apr 25, 2008

hi all,

i want to write SQL query that create table and insert in this table all databases' name and their tables' name that exist in my server.

e.g

DB name Table name
------- ----------

Northwind product
Northwind customers
Northwind Employees
Pubs authors
Pubs discounts
Pubs employee
msdb log_shipping_databases
msdb log_shipping_monitor

View 3 Replies View Related

All Tables In All Databases

Mar 11, 2002

Credit for this script really goes to ToddV (see http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=13737)

The following script issues a DBREINDEX command against every table in every database on your server. It can be modified to issue other commands, but this one in particular is helpful as we are migrating about 30 databases from SQL 7 to SQL 2000 (new server) and re-indexing is recommended. Here's the script:


DECLARE @SQL NVarchar(4000)
SET @SQL = ''

SELECT @SQL = @SQL + 'EXEC ' + NAME + '..sp_MSforeachtable @command1=''DBCC DBREINDEX (''''*'''')'', @replacechar=''*''' + Char(13)
FROM MASTER..Sysdatabases
WHERE dbid > 6 -- skip the 6 built-in databases. Remove to process ALL

PRINT @SQL -- Only if you want to see the code you're about to execute.
EXEC (@SQL)


Notes: There is a limit (nvarchar 4000) to how big your command can be, so too many databases will halt this.

------------------------
GENERAL-ly speaking...

View 2 Replies View Related

Join 2 Tables From 2 Different Databases

Feb 6, 2007

Hi All,
 Is it possible to join 2 tables from 2 different databases in Stored Procedure.
Thanks in advance.

View 2 Replies View Related

How Can I Join Two Tables From Two Different Databases?

Aug 3, 2007

hi,
i have one database ASPNETDB.MDF created by default when adding a user to my site, and MyData.mds - my database...i want to join the aspnet_Users table with another table created by me (in myData.mds), how can i do that? is hard if i should re-write all the data from myData into the ASPNETDB,i even writed both connectionStrings in the web.config but still with no succes...
is there any trick in the SQL statment? please help me
thank you

View 10 Replies View Related

Sending Databases/tables ?

Dec 21, 2007

Hello,
Let's say I created some tables in SQL server using the designer.  Tables -> Right click -> New Table ->... How would I send someone else the script for creating that table?  Or how would I send somebody else the tables?
Thanks.

View 3 Replies View Related

Acess Tables From Different Databases

Jan 23, 2008

I am using Vista Business with Visual Web Developer and Sql Server Express 2005. I want to be able to access the data from two tables in a query. Both tables are attached to the application. 
To refer to the two databases I have used the following
DATABASE.OWNER.TABLE (specifically TaskMgr.dbo.TaskTable)
For both databases I get the error  "Invalid object name"
What am I missing?
Thanks

View 2 Replies View Related

Sharing Tables Between .MDF Databases

Jan 2, 2006

Hi :)

I would like to know if it is possible to link two databases together
(in my case ASPNETDB, and another mdf database) so that I can run
queries on those shared tables. For example, I would like to use the
uniqueidentifiers from the ASPNETDB tables in my own tables.

Thank you!

(I do use the latest version of Visual Web Developer).

View 3 Replies View Related

Updating Of The Tables In Two Different Databases

Dec 16, 2001

I am using SQL server7.0. I am having two databases ,say database A and database B.Database A is the main database which is used in two /three projects.While database B is created by me for my work.From the database A, I am using the 4/5 tables, which i have copied in to the database B.
So, i want to update these tables in the database B as soon as any change (insert,update or delete ) occures on the tables in the database A.
That's why I am interested in doing these work.I have tried, but it doesn't work.So, I have placed these into these forum.
Is any body is having the trigger, procedure ready for doing these job. then plz,mail it to me

View 1 Replies View Related

Combining Two Tables From Different Databases

Jul 2, 2004

I have two databases that each contain the same tables, but different data in the tables. For example, each data contains a table with the same name, arcus, that holds data on our customers. Although the data is different in each table, there is some overlap, particularly in the area of customer number since that is assigned automatically when a customer is entered and serves as the primary key for that table.

To consolidate, I need to merge the two databases. How can I import the data from one table in second database into a table in the first database and append a number to the customer number so that all data will be brought across.

To better illustrate:

database one has an arcus file with a field cusno and contains cusno 1-50
database two has an arcus file with a field cusno and contains cusno 27-58

The overlapping cusno's are not the same customer.

How can I get all the cusno from the arcus file in database two to the arcus file in database one?

Is this even possible?

View 4 Replies View Related

Relating Tables From Different Databases

Nov 29, 2006

Hi,

I am trying to relate two tables but both are from different databases. I have a database 'Current' which has a table 'case' and another database 'Org' which has a table 'employee'. I want to establish a one-to-many relationship between employee and case. I created a coulmn 'employee_key' in the case table & entered values matching the pkey of the employee table. Then I wrote a query using joins to access the table records.

select Org..employee.pkey, Current..case.assignedengineer, Current..case.pkey from Current..case join Org..employee on Current..request.employee_key=Org..employee.pkey

Although the above query works fine, there is no relation between the two tables of the two databases, I wanted to know if this is the right way to achieve what i want to or is there a way in which i can actually create a relationship between tables of two different datbases. Can anyone suggest/help???
Also, I wanted to know if i can relate 1 table of SQL Server db with another table of Oracle DB. Please help ...........
Thanks

View 1 Replies View Related

Join Between Tables On Different Databases

Jan 22, 2004

Is it possible to make a join between two tables from different databases on same server? if yes, how can we do that?

And also if I want to make a join between tables on different databases on different server?how to do this. Please advise.

View 2 Replies View Related

Should I Seperate Tables Into New Databases??

May 22, 2008

My boss has asked me to look into this and I haven't been able to find any information on the web. I hope someone can answer this for me. We currently have a single database that is storing all the user information and transactions. Within the same database we are also logging different types of user activity. If both these tables are heavily used, would it make sense to separate it into different database, one for data and one for logging? Is there any pro or cons of having more than one database? Any opinion or suggestion would be greatly appreciated. I'm the closest thing they have to DBA and I'm really new to this. Thanks.

View 5 Replies View Related

Synchronize 2 Tables In 2 Different Databases

Apr 24, 2007

i have 2 db's that are totally different except that they both have a table users and I want to make it that anytime the user table is updated or added to in one db - that it is copied over to the other db.

is this possible?

View 9 Replies View Related

How To Find No. Of Databases And Tables?

Mar 26, 2008

Hi,
is there any way to find out the no. of databases and
no. of tables in a particular database using a sql query ???

If any server variable is used then please mention that???


thanx in advance

San

View 20 Replies View Related

Joining Tables In Different Databases

Jan 24, 2006

HiI'm working on an ASP project where the clients want to be able toeffectively perform SELECT queries joining tables from two differentdatabases (located on the same SQL-Server).Does this involve creating virtual tables that link to another database, oram I completely on the wrong track?Any hints as to where I might find more information (buzz-words, etc.) wouldbe most appreciated.Thanks

View 10 Replies View Related

Linking Tables From Other Databases?

Jan 18, 2007

In a database, I am creating a new db. From there, I am setting up thetables, so that I can eventually create a front end (usually access,but I may attempt to be brave and lose the shell.) Anyway, I want touse a table, read-only for a lookup. It exists in another database onour system. Is there a way for me to link it into this database that Iam working on? I would think of it like in access when you go to do anew table and you choose to link the table from somewhere else. Thatis what I want to do. Can anyone possibly step me through this?I know basics of sql server and like to learn.Thanks!

View 3 Replies View Related

Retrieve ALL Tables From ALL Databases

Apr 10, 2007

(SQL 2005)I'm looking to create a stored procedure to first "select name fromsys.databases where name like '%site'" then pass each name to thefollowing using some kind of loop "USE @name select name fromsys.tables where type = 'U'"I tried a while statement, but the master sys.databases recordsetdoesn't change..It's the loop I can't get to work.Any help is greatly appreciated!

View 3 Replies View Related

Querying Tables From Different Databases

Jul 20, 2005

Hello,I am quite new to ms-sql and I have a problem : I want to create an SQLrequest which would copy serveral records from a table in a given databaseto another table (with exactly the same structure) in another database(theses two tables and databases already exist).Could you please tell me how to do this ? I dont know how to access twodifferent databases in a single SQL request.Thank you for you help.

View 3 Replies View Related

Combining Tables From Different Databases

Jul 20, 2005

Hi.I'm currently working on a project which involves the creation of aweb page which reports selected data to customers from two back-endsystems. I use ASP script language on IIS, the server is MS SQL 2000.Now I'm struggling with combining two tables from the differentdatabases. I'm sure it's simple enough, but I'm a little short on theSQL expertise.I've got two databases, db1 and db2, and then two tables, db1.t1 anddb2.t2. I need to combine these two tables (both tables have amatching key field) to make a list of all items from db1.t1, and thosewho correspond from db2.t2.I can list all items from db1.t1, but I can't seem to get the db2.t2joined in.Can anybody help me with the syntax for this, please ? Help !Answers, hints & tips greatly appreciated.Thanks in advance !Kenneth

View 2 Replies View Related

Comparing Two Tables In Two Different Databases

Jul 19, 2007

I want to compare the records in a table on my live database server with the same table that is my test database server. How can I do this?

Note that both databases are mirrors of each other but contain slightly different data and are on different servers.

View 4 Replies View Related







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