DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Weird Sql Query

09.28.2009
| 1259 views |
  • submit to reddit
        // description of your code here

select convert(varchar(8),dateadd(dd , i.i * -1, dte.d ),112)
from 
(select 0 AS I union all 
select 1 union 
select 2 union 
select 3 union 
select 4 union 
select 5 union 
select 6
) i
CROSS join 
(select dateadd(dd,0,getdate()) AS D) dte
order by dte.d desc