Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanna create script my whole table, including all statistics and indexes.

In SSM, When I right click table and create script, it gives me script for Indexes for not for statistics.

If I right click indexes, then there is an option to generate script, but this option is disabled when I right click Statistics.

Can anyone tell me how do I generate script for statistics.


share|improve this question

migrated from Apr 30 '13 at 7:50

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

In SSMS, open Tools -> Options and go to the "SQL Server Object Explorer" item in the left-hand pane. Expand that and you should see a "Scripting" subitem. From there, navigate to the "Table and View Options" section and you should see an option to say whether statistics are scripted or not.

share|improve this answer
Great, its the answer, Thanks – Muhammad Sharjeel Ahsan Apr 30 '13 at 6:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.