From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Import a dataset from SQL Server

Import a dataset from SQL Server - SQL Server Tutorial

From the course: Complete Guide to Advanced SQL Server

Import a dataset from SQL Server

So far, we've looked at working with values that are hard-coded in a Python script, but I'm sure what you really want to know is how to work with the data that you've already stored in a SQL Server database. There are three steps of processing SQL Server data with Python. First, import the data that you want to work with in the Python script using a standard T-SQL select query. Second, you're going to do something with that data using Python functions and libraries. And third, you'll then output the process data to a result set that SQL Server understands. Let's focus on the first step; importing the data into the Python script. In addition to the language and the script parameters of the sp_execute_external_script stored procedure, there is another parameter that we can add called input_data_1. Just like language and script, it takes a Unicode value. So it's going to have the capital letter N prefix. And the value of the parameter is a standard T-SQL select query, just like the ones…

Contents