Results 1 to 7 of 7

Thread: Using multiple databases

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Using multiple databases

    We are using MS sequel server and have a production data base provided by a third party. We need to create additional views, stored procedures and even some customized tables.

    My question is: Could we put those in a "customized" data base and still be able to access tables in the prodiction data base? If so, how would a sp or view located in the "customized" db know to look for tables in the "production" db. In my vb program do I need to connect to both data bases and call the sp in the customized data base and it will find the table(s) in the production data base? Also If I have a table in both customized and production data base that need to be part of same sp will that be a problem?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Using multiple databases

    Thread Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Using multiple databases

    Are the custumized db and the orginal on the same database server? If you you can use use the fully qualified path for the object

    dbname.shcemaname.objectname

    If on different servers setup a linked db and then do the same
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: Using multiple databases

    Yes, they are located on the same db server. If I understand you correctly I should be able to use tableA from data base A and and tableB from data base B as long as I use a fully qualified path in my stored procedure, correct? Would I then in my vb program have to open 2 connections like:

    Dim ConnectionString1 = "Data Source=VGIWPW03-SQL3;Initial Catalog=Prod;User Id=xx;Password=yy;"
    and
    Dim ConnectionString2 = "Data Source=VGIWPW03-SQL3;Initial Catalog=Custom;User Id=xx;Password=yy;"
    Last edited by snufse; Jul 3rd, 2008 at 12:58 PM.

  5. #5
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Using multiple databases

    Yes that is correct
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: Using multiple databases

    You will only need two connection strings if your planning to run stored procedures from both databases.

    Otherwise just use the one connection, as your stored procedure will be doing the join across the databases.

    Make sure the username you use has access rights to both databases.

  7. #7
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Using multiple databases

    Just as an additional note, now this thread has already been answered! The complete, expanded syntax is SQLServerInstanceName.CatalogName.OwnerName.Tablename.

    If this were to be expanded to a database upon a second SQL Server instance;upon a different server, you must first link in the secondary SQL server into initial SQL Server instance which will be performing the accessing. This can be done via the management studio UI or by calling the sp_addlinkedserver system stored procedure.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width