Rob Gonda's Blog

sql: view problems after altering a table

This is old news, I know ... but many people don't know it ... When using Views in Microsoft SQL 2000 (haven't checked 2005), after altering a table the view will not update itself automatically ... it will get completely messed up ... the views point to the column number, not name, therefore after adding a field, some of your columns will be shifted.

The solution is simple, yet confusing if you're not aware of it ... you can click edit the view, and all your columns will show fine, but if you open the view they'll be wrong ... all you have to do is edit the view, save it again, and close ... simple, but necessary ...

A co-worker ran into this today and lost precious hours until he chose to ask :) now you know, and knowing is half of the battle.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?727C25FB-3048-7431-E4864E47861B29B8

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
This blog is running version 5.9.003. Contact Blog Owner