Python in Management Studio - print statement - missing result

piotr krudysz 16 Reputation points
2022-05-23T18:13:54.23+00:00

Hi all,

I'm running the simplest Python script in SQL Server Management Studio:

exec sp_execute_external_script
@language = N'Python',
@script = N'print("hello")
'

but the results are outright inconsistent.

Sometimes I get:

"STDOUT message(s) from external script:
hello"

other times I get:

"Commands completed successfully."

It's totally random.

Why is this so? This compromises any hopes for running Python in SQL Server for us.

SQL Server 2017
SSMS v 18.2

Many thanks in advance.

SQL Server Other
{count} votes

2 answers

Sort by: Most helpful
  1. piotr krudysz 16 Reputation points
    2022-06-06T10:24:31.8+00:00

    Hi Erland, hi Cathyji,

    We've reinstalled Python services in SQL Server and that resolved the issue, SSMS now consistently returns results of Python scripts.

    1 person found this answer helpful.
    0 comments No comments

  2. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2022-05-24T08:09:25.84+00:00

    Hi @piotr krudysz ,

    I test this in my environment, it works well in my environment. Run this scripts many times, only get one result. I am using SSMS 18.11 and SQL server 2019.

    Suggest you using the latest SSMS 18.11.1 as Erland mentioned. If it is still not work, please let us know.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.