> > I would like to move them into a new table that can be named
> > Rlog+DATENAME(mm,GETDATE()) so that I get a table with the name like
> > RLogMarch, RLogApril, etc.
> > Anyone have any suggestions?
> You'd probably have to copy and then delete them. This isn't complete,
> but it would be something like this:
> declare @tabname varchar(20)
> Select @tabname = "RadLogs_" + DATENAME(mm,GETDATE())
> Insert Into @tabname
> Select * From RadLogs
> Where DatePart(Month, LogDate) = DatePart(Month, GetDate())
> You could do -1 on the dates to get last month (for example to
> schedule this on the 1st of each mont).
The whole statement has to be build and executed.
DECLARE @query VARCHAR(255)
SELECT @query = 'Insert Into RadLogs_' + DATENAME... + 'SELECT * FROM
RadLogs WHERE DatePart(Month, LogDate) = DatePart(Month, GetDate())'
EXEC @query
Have Fun!
Peter
> declare @tabname varchar(20)
> Select @tabname = "RadLogs_" + DATENAME(mm,GETDATE())
> Insert Into @tabname
> Select * From RadLogs
> Where DatePart(Month, LogDate) = DatePart(Month, GetDate())
For more information about this list, including removal, please
see this URL: http://www.iea-software.com/maillist.html