Automating SQL-Server DBA functions

The following SQL script uses UPDATE STATISTICS for all tables that contain indexes
Consider scheduling a daily database type job that will execute this SQL

/* declare variables */
declare @table_name varchar(30)

/* declare a cursor that will contain a list of table */
/* names to be updated */
declare idx_cursor cursor
for select distinct
from sysobjects a, sysindexes b
where a.type = `U'
and =
and b.indid > 0

/* open the cursor */
open idx_cursor

/* get the first row from the cursor */
fetch next from idx_cursor into @table_name

/* loop through the rows in the cursor */
while @@fetch_status = 0
    /* issue UPDATE STATISTICS */
    EXEC ("UPDATE STATISTICS " + @table_name)
    /* get next table name */
    fetch next from idx_cursor into @table_name