title: Error converting data type nvarchar to uniqueidentifier
body: <p>I am trying to run a MSSQL procedure from python. Basically my python script just executes a stored procedure named as "my_proc" using this part of code</p>
  
  <pre><code>sql_query = """
      use my_db        
      exec dbo.my_proc
  """
  
  res = common.execute_sql(SERVER, USERNAME, PASSWORD, sql_query)
  </code></pre>
  
  <p>The procedure <em>my_proc</em> looks like this</p>
  
  <pre><code>USE [my_db]
  GO
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[my_proc] 
  AS
  BEGIN
    DECLARE @ID NVARCHAR(32) = N'f17584bd-1b19-4847-a9c7-b1560054de69';
    SELECT @ID, CONVERT(uniqueidentifier, @ID);
  
    EXEC msdb.dbo.sp_start_job @job_id = ID      
  END
  </code></pre>
  
  <p>But, when running the script I get the error:</p>
  
  <p><strong>Error converting data type nvarchar to uniqueidentifier</strong></p>
  
  <p>So, it looks like the part below <em>BEGIN</em> where the conversion from nvarchar to uniquetradeidentifer happens, fails.</p>
  
  <p>I also tried</p>
  
  <pre><code>DECLARE @ID uniqueidentifier
  SET @ID = CAST( 'f17584bd-1b19-4847-a9c7-b1560054de69' as uniqueidentifier )
  </code></pre>
  
  <p>but with same error.</p>
  
  <p>What is wrong here?</p>
  
  <p>Initially I had</p>
  
  <pre><code>EXEC msdb.dbo.sp_start_job @job_id = 'f17584bd-1b19-4847-a9c7-b1560054de69'
  </code></pre>
  
  <p>which works when executing the procedure on sql level, but when running that procedure using my python script I got the error:</p>
  
  <p><strong>The specified @job_id ('F17584BD-1B19-4847-A9C7-B1560054DE69') does not exist</strong> </p>
  
  <p>Thanks for any help</p>