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 / SQL Statement syntax e...
Power Automate
Answered

SQL Statement syntax error when using apostrophe

(0) ShareShare
ReportReport
Posted on by 8

Hello everyone,

 

I am struggling with a SQL statement which works well in SSMS but gives syntax error in Power Automate Desktop. Here is my statement:

 

select TRIM(V.[NAME]) AS VENDORNAME, ISNULL(F.[NAME],'zz_Unknown') AS SOFTWARENAME, P.PATCHNAME, P.BULLETINID, L.[PATH] AS SOURCEPATH, D.[DESCRIPTION],
DATEADD(s, CAST(LEFT(CAST(D.[RELEASEDTIME] AS VARCHAR(100)), 10) AS INT), '1970-01-01 00:00:00')
AS DATERELEASED, P.ISSUPERCEDED, P.SUPERCEDEDBY
from Patch P
INNER JOIN Location L ON P.PATCHLOCATIONID = L.LOCATIONID
INNER JOIN Vendor V ON V.VENDORID = P.VENDORID
LEFT JOIN PatchDetails D ON D.PATCHID = p.PATCHID
LEFT JOIN Family F ON F.FAMILYID = P.FAMILYID
where L.[PATH] like '%.msi%' AND DATEADD(s, CAST(LEFT(CAST(D.[RELEASEDTIME] AS VARCHAR(100)), 10) AS INT), '1970-01-01 00:00:00') > '2022-03-14 00:00:00.000'
ORDER BY 7 desc --1,2

 

Aviral_Sangal_0-1649596271474.png

If you see on every apostrophe it is showing an error. Can someone help in correcting this?

  • VJR Profile Picture
    7,635 on at

    Hi @Aviral_Sangal 

    The red color may not necessarily indicate an error.

    For the PAD variable you've got in the query use "%VariableName%".

    They are double quotes.

    Run the query and share what happens.

  • Aviral_Sangal Profile Picture
    8 on at

    Thank you for your response. I think  you are write but the '%.msi%' is not a variable but statement to the lookup command to lookup values that ends with .msi

  • Verified answer
    Karlis Profile Picture
    23 on at

    Hi Aviral_Sangai

     

    Since PAD will assume that anything between the % is a variable, you need to use the escape syntax to make the process understand that you actually need a % sign there.

     

    You can do it by writing '%%.msi%%' - same goes for many other characters.

    Sometimes the escape syntax is \%, I forgot which cases you need to use those. 

     

     

  • Aviral_Sangal Profile Picture
    8 on at

    @Karlis That worked. Thanks a ton.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 211 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 190

Last 30 days Overall leaderboard