February 5, 2007 at 6:16 am
February 5, 2007 at 6:48 am
not an "automatic" way that I'm aware of;
you can make it a habit to recompile objects on a regular basis (exec sp_recompile object name) for all procs, views and functions,
if you just want to recompile objects that refernece just one table you changed, this can get you started: note i limited the where statement to 'view', but you could leave it off for prcs and functions too.
create table #ReferencedBy (ObjectName varchar(64),ObjectType varchar(20))
Insert into #ReferencedBy(ObjectName,ObjectType)
exec sp_depends YOURTABLE
select 'exec sp_recompile ' + ObjectName from #ReferencedBy where ObjectType = 'view'
Lowell
February 5, 2007 at 7:10 am
The * in "select *" actually gets resolved to particular columns when the view is created. It is not then bound to the table. Any changes to the table will not change the view. You essentially need to drop and rebuild the view, though you can use alter instead.
February 6, 2007 at 6:45 am
And yet another reason not to use SELECT * in a view.
February 6, 2007 at 9:28 am
sp_refreshview 'VIEWNAME'
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply