Update all statistics for the database

EXEC sp_updatestats

Update statistics for a group of tables with FULL SCAN

SET NOCOUNT  ON 

DECLARE  @SQLcommand NVARCHAR(512), 
         @Table      SYSNAME 

DECLARE csr CURSOR  FOR 
SELECT table_schema + '.' + table_name 
FROM   information_schema.tables 
WHERE  TABLE_TYPE = 'BASE TABLE' 
 
OPEN csr 
 
FETCH NEXT FROM csr 
INTO @Table 
 
WHILE (@@FETCH_STATUS = 0) 
  BEGIN 
    PRINT N'UPDATING STATISTICS FOR TABLE: ' + @Table 
     
    SET @SQLcommand = 'UPDATE STATISTICS ' + @Table + ' WITH FULLSCAN' 
     
    EXEC sp_executesql @SQLcommand 
     
    FETCH NEXT FROM csr 
    INTO @Table 
  END 
 
CLOSE csr 
 
DEALLOCATE csr 
 
SET NOCOUNT  OFF