change the sql code to a grid

Hello everybody,

Working with sql Server 2005 and have the following code:

DECLARE @facturas nVARCHAR(250),@prv nVARCHAR(250),@poliza nVARCHAR(250)
SELECT @facturas= COALESCE(@facturas + ‘, ‘,’’) + c_codigo_fac,
@prv = COALESCE(@prv + ‘, ‘,’’) + c_codigo_prv,
@poliza = COALESCE(@poliza + ‘, ‘,’’) + c_polizapago_fac
FROM Mytable
where c_codigo_sel=‘0000000681’
select distinct c_codigo_sel,c_liq_cxp,@facturas as Facturas,@prv as Proveedores, @poliza as PolizasPago
FROM Mytable
where c_codigo_sel=‘0000000681’

This code shows me the following output in sql:

Click image for larger version. Name: sql.jpg Views: 7 Size: 15.3 KB ID: 805

And the big question is: How can I make this code shows me the same result in a Grid?
*
I already tried changing the sql code, but I get an error

I hope you can help me with this question

Thanks!!!

sql.jpg

What error are you getting?
Anyways it’s probably a good idea to make a view in your database for this, Scriptcase isn’t all that good in working with complex SQL queries.