Connecting to an external database

From Joomla! Documentation

This is great. Where can you put this code? Not in a custom html module. Where?

Everywhere in the sourcecode (the php files), where you need a new (non-default) database object --Bembelimen 00:39, 20 March 2009 (UTC)

can we pull an external DB that is running SQL server. It looks like we would change the first variable and get the drivers for this but making sure this a possible solution. thanks.