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:

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!!!

Nestor Avina

sql.jpg

Dont use a declare, just use more standard sql… So the one below
SELECT COALESCE(@facturas + ‘, ‘,’’) + c_codigo_fac as facturas,
COALESCE(@prv + ‘, ‘,’’) + c_codigo_prv as prv,
COALESCE(@poliza + ‘, ‘,’’) + c_polizapago_fac as poliza
FROM Mytable
where c_codigo_sel=‘0000000681’

That is more normal sql.