In that scenario you have to use dynamic SQL to create the scripts.
In the columns for the view, the permissions for a column name apply across a CREATE VIEW or ALTER VIEW statement, regardless of the source of the underlying data.
All referenced objects must be in the same database.
dating a serial dater - Ms sql view not updating
Encrypts the entries in sys.syscomments that contain the text of the ALTER VIEW statement.
WITH ENCRYPTION prevents the view from being published as part of SQL Server replication.
The following example creates a script that refreshes the metadata for all views that have a dependency on table USE Adventure Works2012; GO SELECT DISTINCT ' EXEC sp_refreshview ''' name '''' FROM sys.objects AS so INNER JOIN sys.sql_expression_dependencies AS sed ON so.object_id = sed.referencing_id WHERE = ' V' AND sed.referenced_id = OBJECT_ID(' Person.
When a view is created in SQL Server, metadata for the referenced table columns (column name and ordinal position) is persisted in the database.
My purpose is not to solve it here, but rather to ask experienced DBAs and DB developers if: Column positions were altered in some tables: Apparently the customer gave full database access to a consultant for database usage analysis. " (much less anger follows...) it is possible if the underlying table has been changed and sp_refreshview has not been ran against the view, so the view will have missing columns if those were added to the table.
That great guy changed the order of the columns to see the few clauses. To see what I mean read how to make sure that the view will have the underlying table changes by using sp_refreshview You can create views with locking hints which would mean you might be getting a dirty read.0 (success) or a nonzero number (failure) If a view is not created with schemabinding, sp_refreshview should be run when changes are made to the objects underlying the view that affect the definition of the view.Otherwise, the view might produce unexpected results when it is queried.SCHEMABINDING Binds the view to the schema of the underlying table or tables.When SCHEMABINDING is specified, the base tables cannot be modified in a way that would affect the view definition.I always thought, maybe mistakenly, that as underlying tables change, the views that reference them change too. Product Color='Red'; GO -- View definition CREATE VIEW Sales.v_Sales Order Detail2 WITH SCHEMABINDING AS SELECT h.