用企业管理器--右键点你的数据库---所有任务---生成sql脚本---点“全部显示”---点“全部视图”,生成一个脚本文件,然后执行应该就可以了

解决方案 »

  1.   

    --上面写错了,不应该加括号--下面是一次重新编译所有视图
    declare @s nvarchar(4000)
    declare tb cursor local for
    select 'sp_refreshview '''+name+'''' 
    from sysobjects 
    where xtype='V' and status>=0
    open tb 
    fetch tb into @s
    while @@fetch_status=0
    begin
    exec(@s)
    fetch tb into @s
    end
    close tb
    deallocate tb
      

  2.   

    DECLARE cur_view cursor FOR 
    SELECT TABLE_NAME    FROM   INFORMATION_SCHEMA.VIEWSDECLARE @name varchar(40)
    OPEN cur_viewFETCH NEXT FROM cur_view into @name
    WHILE (@@fetch_status <> -1)
    BEGIN
    IF (@@fetch_status <> -2)
    BEGIN
    exec(' sp_refreshview '+@name)
    END
      FETCH NEXT FROM cur_view INTO @name
    ENDCLOSE cur_view
    DEALLOCATE cur_view
    GO