none
update statistics of a table in SQL server 2012

    Question

  • Hi,

    We are using SQL Server 2012, I need to update the statistics of some tables, the name of the tables begin with /.

    If i run "update statistics "DB.schema./BOBF/C_TXC_TST"

    it gives me error  saying " Incorrect syntax near '/'.

    Please let me know how can i update the statistics of such tables and how to check the statistics of the tables?

    Regards

    Thursday, October 31, 2013 6:56 AM

Answers

  • Put in in brackets.

    update statistics db.schema.[/BOBF/C_TXC_TST];

    May I ask WHY someone is doing such a crap ;)
    I've seen many funny things what "developers" have done with SQL Server but this is in the top 5 :)

    SCNR!


    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

    Thursday, October 31, 2013 6:59 AM
  • Try the below query:

    Select name,STATS_DATE(object_id,index_id) 'Last stats updated date'
    From sys.indexes Where object_name(object_id) = 'tablename'

    You can try the below for Column stats also...

    Select name,STATS_DATE(object_id,stats_id) 'Last stats updated date' 
    From sys.stats Where object_name(object_id) = 'tablename'


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.



    Thursday, October 31, 2013 7:06 AM
  • Hi,

    How can I check whether statistics of these tables which begins with '/' are update?

    REgards

    You need to filter the stats or tablename as per your requirement:

    Try the below sample:

    Select name,STATS_DATE(object_id,stats_id) 'Last stats updated date' 
    From sys.stats Where object_name(object_id) = '<tablename>'
    and name like '[/]%'


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    Thursday, October 31, 2013 7:56 AM

All replies

  • Put in in brackets.

    update statistics db.schema.[/BOBF/C_TXC_TST];

    May I ask WHY someone is doing such a crap ;)
    I've seen many funny things what "developers" have done with SQL Server but this is in the top 5 :)

    SCNR!


    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

    Thursday, October 31, 2013 6:59 AM
  • Hi,

    I got a request from upgradation project guys, they are actually uploading the data, 

    How can i check whether the statistics of a table is update?

    Regards

    Bilal

    Thursday, October 31, 2013 7:03 AM
  • Try the below query:

    Select name,STATS_DATE(object_id,index_id) 'Last stats updated date'
    From sys.indexes Where object_name(object_id) = 'tablename'

    You can try the below for Column stats also...

    Select name,STATS_DATE(object_id,stats_id) 'Last stats updated date' 
    From sys.stats Where object_name(object_id) = 'tablename'


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.



    Thursday, October 31, 2013 7:06 AM
  • Hi,

    How can I check whether statistics of these tables which begins with '/' are update?

    REgards

    Thursday, October 31, 2013 7:30 AM
  • Hi,

    How can I check whether statistics of these tables which begins with '/' are update?

    REgards

    You need to filter the stats or tablename as per your requirement:

    Try the below sample:

    Select name,STATS_DATE(object_id,stats_id) 'Last stats updated date' 
    From sys.stats Where object_name(object_id) = '<tablename>'
    and name like '[/]%'


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    Thursday, October 31, 2013 7:56 AM