converting Text data to sql query type

converting Text data to sql query type

  

HI All,

   I prepared a dynamic query in one local variable and trying to pass that query to a SQL as input parameter and i was executing that input parameter in my sql. But query is forming and working very well, If i am executing manually. But that same query is throwing error while i am passing as input parameter. 

     Can anyone suggest me any idea to convert that text type data as sql query type. 


Thanks,

Gopi

Hi Dear, I usually to do this way. I to do conversion in SQL query.

WHERE CONVERT(date, {tblCase}.[OpenDateTime], 101)


Another way to do is to convert before concatenation, for this you will need extension that does it. You can search on Forge.


Gopi Dharmaraju wrote:

HI All,

   I prepared a dynamic query in one local variable and trying to pass that query to a SQL as input parameter and i was executing that input parameter in my sql. But query is forming and working very well, If i am executing manually. But that same query is throwing error while i am passing as input parameter. 

     Can anyone suggest me any idea to convert that text type data as sql query type. 


Thanks,

Gopi

Hi Gopi,

If you are passing a dynamic query as an input, you cannot use the EncodeSql function on it... make sure the Query parameter is assigned the value QueryPreparation.FinalQuery.

The EncodeSql() function is used when you want to sanitise SQL Input Parameters so you cannot inject code into your SQL, but that's exactly what you want to do in this case. 


I'm sorry for my mistake. I thought you were saying about variable type Date and not Data. However keep tip.