Skip to content

Instantly share code, notes, and snippets.

@gugat
Last active May 18, 2017 16:47
Show Gist options
  • Select an option

  • Save gugat/2a91e62db34ad5a1af5b4a21b9069f9b to your computer and use it in GitHub Desktop.

Select an option

Save gugat/2a91e62db34ad5a1af5b4a21b9069f9b to your computer and use it in GitHub Desktop.
SQL Server Loop Date Range
declare @fecha datetime;
declare @fecha_busqueda varchar(8);
set @fecha = '20170501';
while @fecha < '20170531'
begin
set @fecha = dateadd(day,1,@fecha);
set @fecha_busqueda = convert(varchar, @fecha , 112)
select * from tb where fecha = @fecha_busqueda
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment