Binding objects to caches

sp_bindcache assigns a database, table, index, text object, or image object to a cache. Before you can bind an entity to a cache:

Binding objects to caches is dynamic, you need not restart the server.

The syntax for binding objects to caches is:

sp_bindcache cache_name, dbname [,[owner.]tablename
[, indexname | "text only" ] ]

This example binds the titles table to the pubs_cache:

sp_bindcache pubs_cache, pubs2, titles

To bind an index on titles, add the index name as the third parameter:

sp_bindcache pubs_cache, pubs2, titles, titleind

The owner name is not needed in the examples above because the objects in the pubs2 database are owned by “dbo.” To specify a table owned by any other user, add the owner name. You must enclose the entire parameter in quotation marks, since the period is a special character:

sp_bindcache pubs_cache, pubs2, "fred.sales_east"

This example binds the transaction log, syslogs, to the pubs_log cache:

sp_bindcache pubs_log, pubs2, syslogs

The database must be in single-user mode before you can bind any system tables, including the transaction log, syslogs, to a cache. Use sp_dboption from master, and a use database command, and run checkpoint:

sp_dboption pubs2, single, true

text and image columns for a table are stored in a separate data structure in the database. To bind this object to a cache, add the “text-only” parameter:

sp_bindcache pubs_cache, pubs2, au_pix, "text only"

This example, executed from master, binds the tempdb database to a cache:

sp_bindcache tempdb_cache, tempdb

You can rebind objects without dropping existing bindings.