String format error

Hi

I want to keep a SQL code in a string variable. I will pass the variable as a type into activity in browser.

Since the SQL already has “” in it’s showing compilation error. SS are attached. Kindly suggest how can I store an SQL code in string variable:

Hello,
Hope this might help:

Hi this does not answer my query.

I have a SQL code snippet of the below format:

SELECT *
FROM table
WHERE date < todate(date , “dd/mm/yyyy”)

Now I want to store the above in a variable. How should I do it, if I put in string due to “dd/mm/yyyy” this will come as an error.

Thanks. Hope I have explained my situation.

Hi @shrayud

Kindly try the below and let me know whether it’s working or not.

Example: {name:““Your_wording_here””},

Give two double quotes each and try.

Thanks.

Hi Vinesh,

This is still not working.

Hello, I am trying to do the same thing as you. Did you ever figure out how to do it?

I dropped this project, so the issue remains un-solved. One idea I have is to keep “” on all lines. And separating each line by +

Hi @shrayud and @aphrodite123 ,

Alternative 1:
You can remove all double quotes "YOURVALUE" from you SQL query string and instead use single quotes 'YOURVALUE' as atleast Microsoft SQL does support single quotes in the query.

Alternative 2: Recommended way
An even more elegant way to achieve this is to just call a stored-procedure and you will entierly avoid this issue.

This way if you need to add any new logic into the query, you will not need to edit the robot. You will only need to edit your stored procedure in SQL Studio or equivalent editor.

If you pass variables in your query via UiPath your stored procedure can consume them as well. You can read more about how to call a stored procedure here : SQL Stored procedure Passing Parameters To fetch particular records - Help / Activities - UiPath Community Forum If you do not have paramters you only need to call the stored procedure.

Hope this helps you and others.