Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

VB.net SQL Views don't incorporate new columns added to a table

I have a number of Views in my SQL 2014 database that pull data from a number of tables. If I add new columns to one of the tables then run my application that reads the database schema to show all columns from the table doesn't update. Is this because the schema in the database hasn't been updated?
Is there a way to refresh all views so that they bring in new columns?
Microsoft SQL ServerVisual Basic.NET

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
Vitor Montalvão

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Pawan Kumar

In this case use below to get the newly added columns..

EXECUTE sp_refreshview N'ViewName';
Vitor Montalvão

sp_refreshview does NOT add new columns. As it says in the MSDN article it only refreshes the metadata for the view (column data type change or relationships changes for example).
Pawan Kumar

I mean if the user added new columns in the table and if you have "SELECT *" in the view then one has to
use below to get the new column from the view.

EXECUTE sp_refreshview N'ViewName';

It is one of the famous limitation of the views
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Vitor Montalvão

It is one of the famous limitation of the views
Famous? What are the others limitations?
Murray Brown

Thanks very much