home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / msmqocm.cab / UPDATE.SQL < prev    next >
Text File  |  1997-11-10  |  804b  |  59 lines

  1.  
  2.  
  3. CREATE PROCEDURE msmq_update_statistics 
  4. as
  5.     
  6.  
  7.  
  8.  
  9.     declare listtables cursor
  10.         for select name from sysobjects where type = 'U' for read only
  11.  
  12.     declare @name varchar(40)
  13.  
  14.     
  15.  
  16.  
  17.     open listtables 
  18.  
  19.     
  20.  
  21.   
  22.     fetch next from listtables into @name 
  23.  
  24.     
  25.  
  26.  
  27.     while @@fetch_status = 0
  28.         begin
  29.         
  30.  
  31.  
  32.         EXECUTE ("UPDATE STATISTICS " + @name) 
  33.         
  34.  
  35.  
  36.         fetch next from listtables into @name 
  37.  
  38.         end
  39.  
  40.     
  41.  
  42.  
  43.      deallocate listtables 
  44.  
  45. go
  46.  
  47. use msdb
  48. go
  49.  
  50. EXECUTE sp_addtask  @name = 'msmq_update_statistics', @databasename = 'mqis',
  51.                     @enabled = 1, @freqtype = 4, @freqinterval = 1,
  52.                     @activestarttimeofday = 000000, @command = 'msmq_update_statistics' 
  53. go
  54.  
  55.  
  56.  
  57.  
  58.  
  59.