Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ofsouto
Starting Member
22 Posts |
Posted - 2005-01-15 : 13:55:19
|
| Hi, dearA date (GetDate()) is a stored procedure inside parameter.I need to list the last 13 month/year.I need to generate a query where I can get the result bellow:01/200512/200411/2004...02/200401/2004Is it possible? How can I get it without creating a table?Thank you very muchObedeBrazil |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-15 : 14:39:57
|
| declare @dte datetimeselect @dte = getdate()select convert(varchar(6),dateadd(mm,i*-1,@dte),112)from(select i = i1.i + i2.i + i3.i + i4.ifrom(select i = 0 union select 1) as i1 ,(select i = 0 union select 2) as i2 ,(select i = 0 union select 4) as i3 ,(select i = 0 union select 8) as i4) as intswhere i <= 13order by i==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|