Retrieve Records from another database using View

  • Which one is better, create a new view in database-1 to retrieve records from database-2? or directly connect to database-2? Both databases are in the same server.

    Thx

  • Doesn't really matter, if tying to other data in DB1 it is best to use a view. However when using aview you are still connecting to DB2 you just are not defining you connection that way in your app. Consider this.

    COnnection defines INITIAL CATALOG as DB1 and you want to use DB2 data. You can easily do SELECT * FROM DB2.dbo.tbl or change the catalog during runtime with a USE statement. INITIAL CATALOG in a connection means that is the DB context you start out under doesn't mean the only one you can be under.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply