SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

go
DECLARE @CursorVar CURSOR
declare @tablename      varchar(40)
declare @tb1         varchar(40)
declare @dlycnt    int

 DECLARE Bti_cursor CURSOR FOR
      select name from dbo.sysobjects where OBJECTPROPERTY(id, N'IsProcedure') = 1 and uid <> 1

set @CursorVar = Bti_cursor
open @CursorVar
set @dlycnt = 0
FETCH NEXT FROM @CursorVar into @tablename
WHILE @@FETCH_STATUS = 0
  BEGIN
    select @tb1 = 'user.'+ @tablename
    EXEC sp_changeobjectowner @tb1,'dbo'
    select @dlycnt = @dlycnt + 1
    FETCH NEXT FROM @CursorVar into @tablename
  END
CLOSE Bti_cursor


SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

posted on 2007-07-18 08:41  花光月影  阅读(553)  评论(1编辑  收藏  举报