Run query using Declare variable

Hello friends,

Im using a Run query ativity to execute this query:

DECLARE @texto varchar(4000)

SELECT @texto = ISNULL(@texto + ‘’, ‘’) + ‘Produto: ’ + produto +’-‘+ descr +’, quantidade: ‘+ replace(STR(qnt, 6, 2),’.‘,’,‘)+’ valor unitário:‘+replace(STR(valor,6,2),’.‘,’,‘)+ ’ valor total: ‘+replace(STR(valor*qnt,6,2),’.’,‘,’)+'; '+char(13)
FROM Acor_itens , mixmatrizbi2 where produto = codigo and num =‘6’;

print @texto;

image

my connection to data base is ok, i have testing other query and it works weel. But this one UiPath just don´t execute. There isn´t a erro mansagem or fail.

Using a SQL manager studio the query works well.

@Felipe_Moura

Execute query can only be used for select statements… print cannot be used in execute query block which supports only select queries

It might work in execute non query…again that i can’t confirm…but for any statement other than select we generally use non query …

Or you can stored this a sp and then execute the sp instead

Hope this helps

Cheers

Thank @Anil_G.

I will make a program to execute this comanda and get the result at run query using a normal select.

1 Like