Here is a way to connect mssql database using Magento’s inbuilt models.
<?php include_once 'app/Mage.php'; Mage::app(); $host = '';//in the format 127.0.0.1:1433 , 1433 is the default port number $user = ''; // DB user name $pass = ''; // DB password $dbname = ''; //DB name $db = new Zend_Db_Adapter_Pdo_Mssql(array( 'host' => $host, 'username' => $user, 'password' => $pass, 'dbname' => $dbname, 'pdoType' => 'dblib' ) ); try{ $db->getConnection(); }catch(Exception $e) { print_R($e); } $sql = '' ; //SQL query goes here $stmt = $db->query($sql); $qryResult = $db->fetchOne($sql); print_r($qryResult); ?>
Hope this is helpful