Link to home
Start Free TrialLog in
Avatar of Khan Consultoria
Khan ConsultoriaFlag for Brazil

asked on

All the rows from my query result into a text field

hello Guys,

I have a Query that results me 130.000 rows, I need to save all the rows into a txt file.
Today I use my system to do that, row by row and it takes me almost 3 horas processing.
Is there any possibility to have all the rows into a text field, thus I could save all the information
into a file in seconds.

Regards
Alexandre
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Check this article if this is what you need
Avatar of Khan Consultoria

ASKER

Hi John,

I can't do this way, I need to return the information to my system as result into a dataset.

I was thinking about this, for exemplo. But I think it will not be fast

create procedure sp_SPED_Livro_G_Diario_Geral
begin 
  SELECT newid() as chave, 'N' as lido, * into #tmp FROM E001_2018_SPED_Livro_G_Diario_Geral a where 1=1  and (periodo in ('2018') or left(periodo,6) between '201801' and '201812') order by ORDEM_1,ORDEM_2,registro
 
  create table #t(id int, texto text)

  insert into #t (id, texto) values (1, '')

  declare @chave varchar(200);
  declare @linha varchar(1000);

  while exists (select top 1 'x' from #t where lido='N')
  Begin 
    select top 1 @chave=chave, @linha=registro from #tmp where lido='N';
    update #t set texto=texto + @linha where id=1
    update #tmp set lido='S' where chave=@chave
  End

  select * from #t
end

Open in new window


my first problem over there is using text field :(
ASKER CERTIFIED SOLUTION
Avatar of Khan Consultoria
Khan Consultoria
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial