January 11, 2016 at 2:53 pm
Hello
I have an index on a certain column in a table A.
Does any one knows how to tell SQL Server to update the statistics on the column ?
Please 😛
January 11, 2016 at 3:12 pm
January 11, 2016 at 3:27 pm
USE dbx;
GO
UPDATE STATISTICS tabA.ColB;
GO
😛
January 11, 2016 at 10:27 pm
Check out the following link may be this will help you: https://technet.microsoft.com/en-us/library/aa260645(v=sql.80).aspx
January 12, 2016 at 7:20 am
mw112009 (1/11/2016)
UPDATE STATISTICS tabA.ColB;GO
The above is the syntax for updating all stats on a table like below
update statistics schema.table
If you want to update statistics it is
update statistics schema.table.STATISTICSNAME
So create statistics which contains the column and give it a name, then use that name when updating statistics.
So I think the problem may be that you want to find the statistics name that contains the column name that needs to be updated?
Or perhaps the index that has its first key as the column name?
You can do this with below that I cobbled together quick
select o.[object_id] as [ID],SCH.name, o.name as [Table], c.name as [Column],
s.name as statsname,stats_date(o.object_id,i.indid),rowcnt,
rowmodctr --changes since last statsupdate
from sys.objects o
inner join sys.schemas SCH on SCH.schema_id = o.schema_id
inner join sys.columns c on o.[object_id] = c.[object_id]
left join sys.stats s on s.[object_id] = o.[object_id] and s.has_filter = 0
left join sys.stats_columns sc on s.stats_id = sc.stats_id and s.[object_id] = sc.[object_id] and sc.column_id = c.column_id
left join sysindexes I on o.object_id = I.id and i.name = S.name
where sch.name = 'Myschema' and o.name='mytable' and c.name = 'mycolumn'
January 12, 2016 at 10:10 am
What I need is to update statistics on just one column. That column is used by an index.
January 12, 2016 at 10:18 am
mw112009 (1/12/2016)
What I need is to update statistics on just one column. That column is used by an index.
I am assuming you got the index name from the query I attached.
So then you do this.
update statistics schemaname.tablename.indexname with(this could be sampling or fullscan.)
January 12, 2016 at 10:47 am
Cant I just use the following:
UPDATE STATISTICS tabA.ColB;
GO
January 12, 2016 at 10:57 am
Sorry,
I got that (previous ) wrong.
Done!
I used the following:
UPDATE STATISTICS table_name
January 13, 2016 at 2:38 am
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply