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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 add column in a middle of a table ->refresh view

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2005-12-22 : 09:09:15
i have addeda column to a table
in the middle of the table,when i did it and i run a view which is total independet of the new column i got wrong result!
when i open the view made a space (with the space bar) andsaved it again everything worked agin fine! (klike i made some sort of refresh!)
why is that?
how can i avoid this problem?
thnaks in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-12-22 : 09:15:30
it doesn't matter where in the table you added a column.
so your problem is elsewhere.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-22 : 09:26:12
When you do changes via EnterPrise Manager you need to referesh the objects if you changed any. It is better to make use of Query Analyser

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-12-22 : 09:51:06
Check out sp_refreshview in BOL.

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2005-12-25 : 01:54:49
but what if the changed table is contains in 20 diffrent views?
do i need then to sp_refreshview all of them?

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-12-25 : 10:18:54
This is why you shouldn't SELECT * from a table in a view.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-12-25 : 10:20:10
>>do i need then to sp_refreshview all of them?
yes

These things may have avoided you problem:
use an explicit column list to define your views (instead of "select *")
Use query analyzer to alter tables. One reason to use QA is so that new columns are appended to the end of the table instead of inserted between existing columns.

EDIT:
merry x-mas!

Be One with the Optimizer
TG
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2005-12-25 : 14:31:04
i didnt user select * anywhere!
so wahat to do?
and if i inserted it last it whpuld have avoided the problem of refresh?


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page
   

- Advertisement -