473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

View not working SQLSERVER 2000

aaj
Hi all

We have some tables with a couple of layers of very simple views built on
top. In the table are maybe 6 columns and about 15000 records. The first
view cobines the data in the table with some other data from a lookup
table. The second view does some sorting on the first view using certain
dates . They have worked fine for well over a year now.

Until this morning that is... the views stopped returning the full set of
results- even the very simple one that sits just above the table. The view
returned the core of the data from the main table, but nothing from the
lookup table.

In order to get them to work we had to delete each view (using access front
end to do this), and then recreate it with exactly the same SQL text. I am
guessing this causes SQL Server to recompile it. As soon as view 1 had been
recreated it worked, but view 2 still failed, again rebuilding view 2 it
started working.

The only thing I can think of is that this morning I added 2 new fields to
the base table, but I'm sure I've done this before without any (noticable)
problems.

any thoughts as to why it happened would be welcome, I am a bit nervous
now...

thanks

Andy

Jul 20 '05 #1
5 1556
aaj (a.*@c.com) writes:
Until this morning that is... the views stopped returning the full set of
results- even the very simple one that sits just above the table. The view
returned the core of the data from the main table, but nothing from the
lookup table.
...
The only thing I can think of is that this morning I added 2 new fields to
the base table, but I'm sure I've done this before without any (noticable)
problems.


That can indeed be a problem. Particularly if the SELECT list includes
*, for instace "SELECT tablea.*, ...".

Rather than recreating the view, you can use sp_refreshview.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
aaj
Thanks for the prompt reply (feel a bit better now)

do you know why this is the case.... is it just when you refresh the base
table?

thanks in advance

Andy
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn**********************@127.0.0.1...
aaj (a.*@c.com) writes:
Until this morning that is... the views stopped returning the full set of results- even the very simple one that sits just above the table. The view returned the core of the data from the main table, but nothing from the
lookup table.
...
The only thing I can think of is that this morning I added 2 new fields to the base table, but I'm sure I've done this before without any (noticable) problems.


That can indeed be a problem. Particularly if the SELECT list includes
*, for instace "SELECT tablea.*, ...".

Rather than recreating the view, you can use sp_refreshview.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

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

Jul 20 '05 #3
Though I can't give a technically accurate answer, I can tell you that
we experience the same thing here all the time.

The problem appears to only happen when the view has a "*" in it.
Like:

Select *
From table

My best explination is that the view creates a field list based on the
"*" at the time the view is created. Because you didn't give it the
list of fields and instead used the wild card "*" - it creates the
list of fields for you. My best guess is that somehow this derived
list is by reference somehow.

When you change the table, but don't recreate the view then the
"derived referenced" field list becomes invalid (this is the part I
can't explain).

You can keep this from happening by not using "*" in the view, and
instead list the fields explicitly yourself. Or, as you discovered,
recreate the view after changing the table.

Hope this helps.
Jul 20 '05 #4
Shane (sh***@accountix.com) writes:
Though I can't give a technically accurate answer, I can tell you that
we experience the same thing here all the time.

The problem appears to only happen when the view has a "*" in it.
Like:

Select *
From table

My best explination is that the view creates a field list based on the
"*" at the time the view is created. Because you didn't give it the
list of fields and instead used the wild card "*" - it creates the
list of fields for you. My best guess is that somehow this derived
list is by reference somehow.


Yes, this is exactly the issue.

This script illustrates:

CREATE TABLE nisse (a int NOT NULL)
go
CREATE VIEW nisse_view AS SELECT * FROM nisse
go
INSERT nisse (a) VALUES (9)
go
SELECT * FROM nisse_view
SELECT * FROM syscolumns WHERE id = object_id('nisse_view')
go
ALTER TABLE nisse ADD b datetime NOT NULL DEFAULT getdate()
go
SELECT * FROM nisse_view
SELECT * FROM syscolumns WHERE id = object_id('nisse_view')
go
exec sp_refreshview nisse_view
go
SELECT * FROM nisse_view
SELECT * FROM syscolumns WHERE id = object_id('nisse_view')
go
DROP VIEW nisse_view
DROP TABLE nisse

Generally using SELECT * in production code is generally considered
to not be best practice.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #5
aaj
Many thanks for the above, I think I will stop using *,

I suppose its just been a bit of laziness on my part, especially when
working with lots of columns.

thanks again

Andy

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn**********************@127.0.0.1...
Shane (sh***@accountix.com) writes:
Though I can't give a technically accurate answer, I can tell you that
we experience the same thing here all the time.

The problem appears to only happen when the view has a "*" in it.
Like:

Select *
From table

My best explination is that the view creates a field list based on the
"*" at the time the view is created. Because you didn't give it the
list of fields and instead used the wild card "*" - it creates the
list of fields for you. My best guess is that somehow this derived
list is by reference somehow.


Yes, this is exactly the issue.

This script illustrates:

CREATE TABLE nisse (a int NOT NULL)
go
CREATE VIEW nisse_view AS SELECT * FROM nisse
go
INSERT nisse (a) VALUES (9)
go
SELECT * FROM nisse_view
SELECT * FROM syscolumns WHERE id = object_id('nisse_view')
go
ALTER TABLE nisse ADD b datetime NOT NULL DEFAULT getdate()
go
SELECT * FROM nisse_view
SELECT * FROM syscolumns WHERE id = object_id('nisse_view')
go
exec sp_refreshview nisse_view
go
SELECT * FROM nisse_view
SELECT * FROM syscolumns WHERE id = object_id('nisse_view')
go
DROP VIEW nisse_view
DROP TABLE nisse

Generally using SELECT * in production code is generally considered
to not be best practice.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

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

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve | last post by:
Hi; I went to the microsoft site to try to find a guide to the error messages that the jdbc drivers give ( for sqlserver 2000 ). I had no luck. Does anyone know if there is such a guide? ...
3
by: YURYSSG | last post by:
I migrated a DB from Access 2000 to SQLserver 2000. The tables are OK, but I see the old Access views... as TABLE in SQLserver!! Any suggestions? --
2
by: Patrox | last post by:
Hi ! when installing sqlserver 2000 on a Windows 2003 server it explicitly tells "server not compatible with Windows 2003" during install, but it can carry on. After we applied serfice pack 3a...
15
by: Patrick | last post by:
I set my web.config as follows: <authentication mode="Windows" /> <identity impersonate="true" /> Logon to my ASP.NET website as a user who can authenticate to the target database. 1) Works...
3
by: Dan Sikorsky | last post by:
Can I use SQLServer 2000 with ASP.NET 2.0 instead of SQLServer 2005, and use the .Net 2.0 Membership functionality? I've setup my Login page, controls, etc., and now it's time to use the Web...
9
by: Siddu | last post by:
Hi All, I am new to this group and this is my first doubt i am facing at present. I am doing data migration. In this sequence i need to alter few views. Alter in the sense, inside the...
2
by: =?Utf-8?B?SmVmZnJleQ==?= | last post by:
I have some old ASP programs w/ SQLserver 2000 databases. Now I am developing ASP.NET projects using VB 2005 and SQLserver 2005. What are the best procedures to develop and test the ASP.NET...
0
by: squrel | last post by:
Hello All... I m getting this error in my project " Unable to locate record. verify that first column of view gird is unique" .. i have checked my gird and nothing wrong.. checked my database and ...
4
by: emanning | last post by:
I'm having problems using "<>" as criteria for a varchar column in a view. The data in this column is '2008-2009' which is supposed to mean year 2008 thru 2009. If I set the criteria to "=...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.