Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 A View problem

Author  Topic 

DaSaint
Starting Member

9 Posts

Posted - 2002-03-15 : 14:43:58
Hi,

I'm using SQL Server 7 and I have a View with a query on different tables. When I change the structure of one of those tables, the view don't follow those changes I've made.

Like if my view is "Select * from XYZ" and I add a field to the table XYZ, I need to go in the SQL Enterprise manager and make Apply on the view or I need to Drop and ReCreate the view.

Why ? And how can I fix this ? Because I don't want to run a script on my customer Server avery time I make a change on the tables structure...

Thank You,

DaSaint
webmaster@obscuresun.com

Jay99

468 Posts

Posted - 2002-03-15 : 14:53:19
sp_refreshview

Jay

EDIT: you still gotta run this to update the view metadata, but its pretty simple. I don't think there is a way to 'make the view refresh itself' . . .


Edited by - Jay99 on 03/15/2002 14:55:19
Go to Top of Page

DaSaint
Starting Member

9 Posts

Posted - 2002-03-15 : 15:10:31
Jay99,

Thanks a lot for the fast answer.

I should have though of this,

DaSaint
webmaster@obscuresun.com
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-03-15 : 16:26:45
I've never tried this but could you put an update trigger on the sysobejcts table (or whatever system table stores the view info), and call sp_refreshview if the view in question was the one updated?

A bit overkill maybe......

Michael

Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-03-15 : 16:30:18
quote:

I've never tried this but could you put an update trigger on the sysobejcts table


Whether you can or not, Microsoft strongly discourages putting triggers on any system tables.

------------------------
GENERAL-ly speaking...
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-03-15 : 17:10:47
Ahh, well that makes sense.
Just tossing out an idea, seeing if it stuck.

Michael

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-15 : 17:21:20
Not trying to beat a dead horse, but just so you see what modifying the system tables can do:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=12672

Go to Top of Page
   

- Advertisement -