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.
| Author |
Topic |
|
dshelton
Yak Posting Veteran
73 Posts |
Posted - 2003-10-29 : 17:58:53
|
| Hi,Recently I have had a couple of problems with views, I look at the code and it should be working fine but returns different values. When I recompile the view it starts working fine again. Has anyone had a similar issue? And do I need to recompile these views regularly to make sure this doesn't happen again? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-10-29 : 18:59:52
|
| What do you mean recompile a view? Are you running the latest service pack for SQL Server, just in case this is a bug?Tara |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-10-29 : 19:02:44
|
| Maybe show us some code ?Damian |
 |
|
|
dshelton
Yak Posting Veteran
73 Posts |
Posted - 2003-10-29 : 19:54:00
|
| yeah I think this may be a bug of some sort, the view was just a basic statement...SELECT * FROM table1JOIN table2ON id1 = id2the view was returning the these valuesid desc1 SampleData2 SampleData23 SampleData3but when I ran the view as a normal select statement it returned more values..... this is the exact same statement. So I just ran an ALTER VIEW statement to see what happened. Then reran the view and it was ok..... I was just wondering if anyone has had this problem and if they know why it happened. |
 |
|
|
dshelton
Yak Posting Veteran
73 Posts |
Posted - 2003-10-29 : 19:54:33
|
| yeah I think this may be a bug of some sort, the view was just a basic statement...SELECT * FROM table1JOIN table2ON id1 = id2the view was returning the these valuesid desc1 SampleData2 SampleData23 SampleData3but when I ran the view as a normal select statement it returned more values..... this is the exact same statement. So I just ran an ALTER VIEW statement to see what happened. Then reran the view and it was ok..... I was just wondering if anyone has had this problem and if they know why it happened. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-10-29 : 19:59:06
|
| So, you're saying that when you ran:SELECT * FROM MyViewThat it had different results than:SELECT * FROM table1JOIN table2ON id1 = id2?Tara |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-10-29 : 20:04:06
|
| Here is a longshot...Do you have any tables with the same names but different owners ?It could be a problem with the user context, i.e. dbo.MyTable has different data to otheruser.MyTable.Damian |
 |
|
|
dshelton
Yak Posting Veteran
73 Posts |
Posted - 2003-10-29 : 20:17:53
|
| Yeah the views return different values. I've never had this problem before but I've had it twice this week... there is no ownership problems as I'm the only person touching them.The wierd thing is after I just run an ALTER VIEW it is ok. I'm thinking it might be something I'm doing but I don't know what it could be. |
 |
|
|
|
|
|