Drupal: Access External MS SQL Data with Views

With Drupal 7 it is now possible to connect multiple databases of different types. We can now use Views to look at data from Microsoft SQL, MySQL, and other databases regardless of which database is used for Drupal itself. The catch at the moment is that Drupal needs to be installed on a Microsoft machine to use the MS SQL driver sqlsrv, but soon some enthusiastic programmers will have a driver written for whatever other setup you might have.

    My setup:
  • Drupal 7
  • Microsoft Server 2008 r2
  • IIS with the Web Platform Installer for adding the needed PHP features
  • MySQL for the default database
  • MS SQL 2008 for the remote database (used MSSQL2012 for development)
    My starting point:
  • Drupal was installed on IIS and working for a couple months on a production site.
    Modules I added:
  • sqlsrv: http://drupal.org/project/sqlsrv see the release notes for information on installing this module http://drupal.org/node/1207972
  • MyDatabase Views: This is a custom module I modified for my database and copied form here http://drupal.org/node/1417982

I installed sqlsrv following the directions. Its important to follow the installation instructions and to make sure the php modules are added to the server. Then I created the custom database module and replaced the database and table names with my remote connection names. I also added the remote MS SQL database information to the settings.php file. Finally I created a new view and selected the my new database connection for the 'show' field.

Read More