Hi All,
I am trying to UPDATE STATISTICS for a table in a database and when I do so and verify the count of the table, I still get the old stats from the sysindexes table. I was wondering whenever a table is truncated, loaded with data and then updated with the statistics why wouldn't it still show up the old statistics and not the new statistics.
Here are the couple of queries I'm executing. FYI, the structure of both the Source and Report tables are same.
-- Truncate the Table TRUNCATE TABLE [MyReportDatabase].[MySchema].[MyReportTable]
-- Load data from my Source table to Report table INSERT INTO [MyReportDatabase].[MySchema].[MyReportTable] SELECT * FROM [MySourceDatabase].[MySchema].[MySourceTable]
-- Update the Statistics of MyReportTable and get the Count of the records that were just updated. UPDATE STATISTICS [MyReportDatabase].[MySchema].[MyReportTable] SELECT Max([rows]) FROM [MyReportDatabase].[MySchema].[sysindexes] WHERE [id] = object_id('[MyReportDatabase].[MySchema].[MyReportTable]')
Thanks
Known is a DROP, Unknown is an OCEAN.