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.

Output a result set to SQL Server

Output a result set to SQL Server - SQL Server Tutorial

From the course: Complete Guide to Advanced SQL Server

Output a result set to SQL Server

The Python scripts that I've shown you up to this point have simply been printing the results out to the messages window, which isn't really useful for SQL Server. In order to pass back the data in a format that can be used by SQL Server applications or reports, you'll need to convert the Python data frame back to a SQL server result set. To do this, we need to make use of one more variable called output data set. Here's a script that we wrote in the last movie. It imports a couple of columns from the Application.Cities table in the Wide World Importers database using this select statement. It does that in the input_data_1 property of the execute command. Then that data is stored in a data frame called input data set that we're using up here in the script. We're using the iloc property to pull out five rows starting at Index Position Number 5. We then use the print function to output the results to the messages window. If I execute the scripts, you'll see the result. Now, instead of…

Contents