Binding objects to caches

sp_bindcache assigns a database, table, index or text/image object to a cache. Before you can bind an entity to a cache, the following conditions must be met:

Binding objects to caches is dynamic.

The syntax for binding objects to caches is:

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

The owner name is optional if the table is owned by “dbo.”

This command 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 parameter in quotation marks, since the period in the parameter is a special character:

sp_bindcache pubs_cache, pubs2, "fred.sales_east"

This command 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
use pubs2
checkpoint

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 command, executed from master, binds the tempdb database to a cache:

sp_bindcache tempdb_cache, tempdb

You can rebind objects without dropping existing bindings.