Ensure your view and function meta data is upto date.

You will see if you use views and functions that SQL Server holds the rowset metadata for this in system tables. This means that if you change the underlying tables, columns and data types your views and functions can be out of sync.

This is especially the case with views and functions that use select *

To get the metadata to be updated you need to use sp_refreshsqlmodule.

This forces the object to be “re run” into the database and the meta data updated.

Thomas mentioned sp_refreshview which is a wrapper for sp_refreshsqlmodule in his blog post http://thomaslarock.com/2010/04/refresh-your-views-with-sp_refreshview/ This talks about best practice when upgrading and moving databases around.

Published 29 April 2010 15:29 by simonsabin

Comments

29 April 2010 15:47 by SimonS Blog on SQL Server Stuff

# Ensure your view and function meta data is upto date.

You will see if you use views and functions that SQL Server holds the rowset metadata for this in system

# Twitter Trackbacks for Ensure your view and function meta data is upto date. - Simons SQL Blog [sqlblogcasts.com] on Topsy.com

Pingback from  Twitter Trackbacks for                 Ensure your view and function meta data is upto date. - Simons SQL Blog         [sqlblogcasts.com]        on Topsy.com