This script access the database "myDatabase" on the server "myServer", which has a table called "table1". You can change these to point to a database in your environment.
We start by creating an ADODB connection object, give it a connection string, and then open it. The connection string tells ADO to use the SQL OLEDB database provider, and to use our current Windows logon credentials (Integrated Security=SSPI).
Next, we create an ADODB recordset object, and call the open method, passing it our SQL query, and point it at our connection. We can then walk through the records.
Rather than hard-code the field names (after all, I can only imagine what's in your crazy database), this script enumerates the fields with a for loop, then prints each field name and value for each record.
Stay Tuned for more SQL related Perl scripts...