Wednesday, March 7, 2012

my update index script broke...

I have tables now use name that is funkie liked dbo.Address

For example,

use AdventureWorks

select *

from Person.Address

works fine. But, if I wanted to update all table statistics with this script

select 'update statistics ' , name from sysobjects where type = 'U';

won't give the correct tablename as Person.Address. tablename shows only Address. What is needed so the script will provide the correct 2 part names?

Thanks.

you can leverage maintenance plans if your not using Express to update stats. But if you still need to use tsql for it this works against a 2005 instance...

select 'update statistics ' + S.[name] + '.' + O.[name] As GenedSQL

from sys.objects O

inner join sys.schemas S on (O.Schema_ID = S.Schema_ID)

where type = 'U';

|||

Thanks you VERY much.

It works!

|||

please mark an answer then.

Thanks,

Derek

No comments:

Post a Comment