web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Action 'Execute_stored...
Power Automate
Answered

Action 'Execute_stored_procedure_(V2)' failed due to the SQL conversion from a character string to uniqueidentifier

(0) ShareShare
ReportReport
Posted on by 126

I have a stored procedure, which accepts a parameter. The parameter's type is an uniqueidentifier. I've pass the correct format, why did it always failed with the error conversion failure? Anyone can help!!!

Zhangzhonghao_0-1617427921467.png

{
  "status"400,
  "message""Microsoft SQL: Conversion failed when converting from a character string to uniqueidentifier.\r\n     inner exception: Microsoft SQL: Conversion failed when converting from a character string to uniqueidentifier.\r\nclientRequestId: a866fd12-c4cf-4f04-b203-e86de3ee59c8",
  "error": {
    "message""Microsoft SQL: Conversion failed when converting from a character string to uniqueidentifier.\r\n     inner exception: Microsoft SQL: Conversion failed when converting from a character string to uniqueidentifier."
  },
  "source""sql-ea.azconn-ea.p.azurewebsites.net"
}
Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,383 Most Valuable Professional on at

    Unique Identifiers are GUIDs, not strings, and there is no automatic conversion.  Try using GUID() to cast the string to a GUID and use that for your parameter.

  • Zhangzhonghao Profile Picture
    126 on at

    Hi @Pstork1 , thanks for your replying! I just tried to use guid() function to convert, but it still failed. Any idea for this? 

    Zhangzhonghao_0-1617461234094.pngZhangzhonghao_1-1617461293632.png

     

     

  • Verified answer
    Pstork1 Profile Picture
    69,383 Most Valuable Professional on at

    First, my apologies.  I should read documentation more closely.  You can't use Guid() to cast a string to a guid.  It always produces a new guid.  But I did go back and try your scenario.  SQL should accept a straight string in the right format as a guid.  Can you share how the parameter is defined in the stored procedure and what you are using it for?  I built a simple table with a uniqueIdentifier as a Key and then executed the following stored procedure feeding the Guid in as a string.  It works.

     

    ALTER PROCEDURE [dbo].[selectbyGuid]
    	@GuidId UNIQUEIDENTIFIER
    AS
    BEGIN
     -- SET NOCOUNT ON added to prevent extra result sets from
     -- interfering with SELECT statements.
     SET NOCOUNT ON
    
     -- Insert statements for procedure here
     SELECT FieldA,FieldB from dbo.SQL
    	Where Id = @GuidId 
    END

    I also ran it with the GUID you are using and it worked correctly.  No data was returned but it did accept the GUID as a valid parameter.

     

  • Zhangzhonghao Profile Picture
    126 on at

    @Pstork1 thanks for your solution! It turned out that we have incorrect type define of UNIQUEIDENTIFIER (We defined it varchar)...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard