Troy's Blog

Life, family, work, and my experiences with products, services, stores, and the people I encounter each and every day.

My Photo
Name: Troy Pullis
Location: Minneapolis, Minnesota, United States

Tuesday, June 20, 2006

SQL view error "more column names specified than columns defined"

If you ever get a ColdFusion error message such as the following:

Error Executing Database Query. [Macromedia][SQLServer JDBC Driver][SQLServer]View or function 'dbo.myviewname' has more column names specified than columns defined.

You/somebody probably just added or deleted a column from the view definition. Then, if you have a cfquery that does a "select *" against the view, that error will result.

The fix is to run the following system stored procedure in SQL Query Analyzer, to refresh the view.
sp_refreshview 'myviewname'