Thursday, March 4, 2010

Change the ownership in a table

ALTER SCHEMA ers TRANSFER dbo.ers_time

It means change the table ers_time from dbo to ers

  The result is that dbo.ers_time is replaced by  ers.ers_time

Script used to perform this job

with mycte as
(
select cast('2009-02-01' as datetime) DateValue
union all
select DateValue + 1
from    mycte  
where   DateValue + 1 < = GetDate()
  )
  insert into dbo.ers_time(call_dt)
  select datevalue from mycte
OPTION (MAXRECURSION 0)

 

Useful link:  http://www.kodyaz.com/articles/sql-server-dates-table-using-tsql-cte-calendar-table.aspx

No comments:

Post a Comment