4>
5>
6> DROP PROCEDURE pr_updateindex
7> GO
1> CREATE PROCEDURE pr_updateindex
2> AS
3> SET NOCOUNT ON
4> DECLARE getindex_curs CURSOR
5> FOR
6> SELECT name FROM sysobjects WHERE type = 'U'
7> DECLARE @holdtable varchar(30)
8> DECLARE @message varchar(40)
9> DECLARE @dynamic varchar(51)
10> OPEN getindex_curs
11> FETCH NEXT FROM getindex_curs into @holdtable
12> WHILE @@FETCH_STATUS = 0 BEGIN
13> SELECT @dynamic = "UPDATE STATISTICS " + @holdtable
14> SELECT @message = "Updating " + @holdtable
15> EXEC (@dynamic )
16> PRINT @message
17> FETCH NEXT FROM getindex_curs into @holdtable
18> END
19> CLOSE getindex_curs
20> GO
1>
2> EXEC pr_updateindex
3>
4>
5>
|