------------------------------------------------------------------------------------------------------------------------------------------
-- MSSQL 모든테이블 통계 업데이트
------------------------------------------------------------------------------------------------------------------------------------------
DECLARE @SQL VARCHAR(5000)
SELECT @SQL = ''

DECLARE TAB_CUR CURSOR FOR
      SELECT A = 'UPDATE STATISTICS ' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
       WHERE TABLE_TYPE = 'BASE TABLE'
      
OPEN TAB_CUR
FETCH NEXT FROM TAB_CUR INTO @SQL
WHILE(@@FETCH_STATUS = 0)
BEGIN
   EXEC (@SQL)
   FETCH NEXT FROM TAB_CUR INTO @SQL
END      

CLOSE TAB_CUR
DEALLOCATE TAB_CUR


WRITTEN BY
테네시왈츠
항상 겸손하게 항상 새롭게 항상 진실하게

,