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
 General SQL Server Forums
 New to SQL Server Programming
 identical views - different outputs

Author  Topic 

selahlynch
Starting Member

2 Posts

Posted - 2010-08-23 : 11:34:42
I have the following SQL for two different views:


SELECT MasterNadedId, genus, TaxonNameFull, is_diatom
FROM dbo.AlgaeTaxaFull
WHERE (TaxonNameFull LIKE 'Unk%') OR
(TaxonNameFull LIKE '% sp.%')


Two views with the exact same SQL. However, when I select data from one view, it works no problem. When I select data from the second view, it will not return the is_diatom field. I get an error message "Invalid column name 'is_diatom'."

Has anyone experienced something like this? Is it possible for a view to become corrupted?

Thanks,
Selah

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-08-23 : 11:47:12
are they in the same database? are they owned by the same schema?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-23 : 12:19:32
May be its selecting from another view which does not involve that column from this base table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

selahlynch
Starting Member

2 Posts

Posted - 2010-08-23 : 14:59:15
Both views belong to the same database. Both views are owned by the same schema. Both views have the exact same SQL statement and thus select from the same tables/views.

The only difference I can find is in the properties. For one view, the Quoted Identifier property is set to True. For the other view, the one that I have a problem with, the Quoted Identifier property is set to False.

I'd like to experiment with changing this, but I cannot figure out how to change the Quoted Identifier property for a view.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2010-08-23 : 16:19:58
QUOTED_IDENTIFIER can affect the way results are retrieved.. check books online for detailed explanation.. it basically sets how SQL Server treats single and double quotes.. and can be set at the batch level or command level.. script out your stored procedure from SSMS and you will see what option was set.. unless you are overriding this from your application, thats what SQL Server is using.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-08-23 : 21:49:52
show the DDL for both views
Go to Top of Page
   

- Advertisement -