Home > Archive > Microsoft SQL Server forum > September 2005 > View field content update when "real" table fields change









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author View field content update when "real" table fields change
Silas

2005-09-01, 7:24 am

Hi,

I use view to join difference table together for some function. However,
when the "real" table fields changed (e.g. add/delete/change field). The
view table still use the "old fields".

Therefore everytimes when I change the real table, I also needed open the
view table and save it by SQL enterprise manager manually for update the
view table field.

Can we use a SQL command or other method to update it directly?

Regards,
Silas


David Portas

2005-09-01, 7:24 am

So you are using SELECT * in your views rather than list the column
names? That's not a good idea. if you forget to update the view the
results can be unreliable when you drop and then add a column. Best
practice is to list the columns individually.

Do you always make schema changes directly through Enterprise Manager?
As you are discovering, that's hard work. Use scripts to make any
schema changes. You have more control that way, you also have a record
of what changed, you can more easily roll back changes if you need to
and you can reliably test out the change before you deploy it into
production. Using a script just requires an ALTER VIEW statement to
update your view. If you use Query Analyzer to do it then you don't
even need to type the column names yourself - drag the column list from
the Object Browser.

--
David Portas
SQL Server MVP
--

markc600@hotmail.com

2005-09-01, 7:24 am

Check out sp_refreshview in BOL

Erland Sommarskog

2005-09-01, 8:23 pm

David Portas (REMOVE_BEFORE_REPLY
ING_dportas@acm.org) writes:
> Do you always make schema changes directly through Enterprise Manager?
> As you are discovering, that's hard work.


Add to that the Modify Table function has some really horrible bugs, and
there are several problems with the scripts they generate.




--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Silas

2005-09-01, 8:23 pm

Thanks and it works.

<markc600@hotmail.com> wrote in message
news:1125574851.630160.109810@g44g2000cwa.googlegroups.com...
> Check out sp_refreshview in BOL
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com