SQLTeam.com | Weblogs | Forums

How to refresh the tables in a database


I was wondering if there is a way to refresh the tables in explorer through TSQL code, or something.
Normally I go to the top and right click on the database and hit refresh. However, I have a lot of tables and it would be easer to do it in code.
Thank you


The refresh is for SSMS and does not do anything on the actual database. The database already has the changes you are making, it's just that SSMS doesn't reflect it yet until you refresh it.

If you want to see the results in a query window instead, you can use INFORMATION_SCHEMA views, sysobjects, sp_help, etc. But you'll need to get comfortable with the various commands. The results will not be in object explorer but rather in a query window.


Thanks, but I really want to see the items refreshed in explorer, without having to go all the way to the top and refresh. I know it is there just not in the view. So if I create a table for example, I will not see it unless I do this.


It's not possible with TSQL to refresh object explorer.


Okay thanks


I'd never thought about it before, but I want that too!

I work solely in Scripts, so I don't really need SSMS Object Explorer, but when I am using SSMS Designer (to then make a script, and run it) I always press REFRESH on the specific table (or TABLES if I am adding a new one). The reason is that, if I don't, I might get an old, stale, cached copy if I subsequently use Design on that table.

Given that I don't use SSMS much the time I have spent scrolling and pressing refresh is considerable ... surely someone who Lives and Dies in SSMS must waste far more time?

Seems reasonable to me that SSMS could detect a "schema change" and refresh the object explorer (or whenever you open / expand a Table a quick check of whether the local cached ModifedDate is the same as sys.tables would be enough to figure out if a just-in-time refresh was required.

I'm sure it will be in the next version ... :chug: