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

Notifications

Announcements

Community site session details

Community site session details

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

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
    68,697 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
    68,697 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard