How to Query Microsoft SQL Server from Linux

WMI eventsIn a perfect system administrator’s world, everything would be the same. All servers would be identical, run the same workloads on the same configurations and perform equally. If only wishing made it so. System administrators must manage a heterogeneous environment full of different OS flavors, configurations and so on. This couldn’t be more evident in the need to perform SQL queries from a Linux machine.

Read on to find out one way that will allow you to perform any number of T-SQL queries to a SQL Server machine. I’ll be using Ubuntu 16.04, and I will be querying a SQL Server 2012 R2 machine. However, the same technique should apply to other Linux flavors and SQL Server versions.

To get started, we’re going to need to install a few prerequisites. We’re going to be querying SQL Server from Python, so we’ll need a prerequisites Python module called PyODBC. This module allows you to query any number of ODBC databases. To get this installed, we’ll use pip (the Python package manager)…

Read the full article at TomsITPro.

Adam Bertram

Adam Bertram

Chief Automator at Adam the Automator, LLC
Adam Bertram is an independent consultant, technical writer, trainer and presenter. Adam specializes in consulting and evangelizing all things IT automation mainly focused around Windows PowerShell. Adam is a Microsoft Windows PowerShell MVP, 2015 PowerShell hero and has numerous Microsoft IT pro certifications. He authors IT pro course content for Pluralsight, is a regular contributor to numerous print and online publications and presents at various user groups and conferences.You can find Adam here on the blog or on Twitter at @adbertram.
Adam Bertram

Latest posts by Adam Bertram (see all)

Leave a Reply