Strange Query Results

  • Thread starter Thread starter tkosel
  • Start date Start date
T

tkosel

I am trying to get data from a SQL Server Database using Access 2003. I have
linked to the appropriate table.

My Access Query SQL Follows.

SELECT dbo_L_DATA.LBL_ID, dbo_L_DATA.LBL_VALUE
FROM dbo_L_DATA
WHERE (((dbo_L_DATA.LBL_ID)=166955724)) OR (((dbo_L_DATA.LBL_ID)=117851648))
ORDER BY dbo_L_DATA.LBL_VALUE;

When I run it, I get the following values returned:

LBL_ID LBL_VALUE
117851648 Value2
117851648 Value2


In SQL Server Enterprise manager, I build the followng Query:

SELECT LBL_ID, LBL_VALUE FROM L_DATA WHERE (LBL_ID = 166955724) OR
(LBL_ID = 117851648)

It returns:

LBL_ID LBL_VALUE
166955724 Value1
117851648 Value2

This is the data I input for this stuff, this is what I expected to get.
Any reason why I am not getting it in the access query? Any help would be
much appreciated.
 
tkosel said:
I am trying to get data from a SQL Server Database using Access 2003. I have
linked to the appropriate table.

My Access Query SQL Follows.

SELECT dbo_L_DATA.LBL_ID, dbo_L_DATA.LBL_VALUE
FROM dbo_L_DATA
WHERE (((dbo_L_DATA.LBL_ID)=166955724)) OR (((dbo_L_DATA.LBL_ID)=117851648))
ORDER BY dbo_L_DATA.LBL_VALUE;

When I run it, I get the following values returned:

LBL_ID LBL_VALUE
117851648 Value2
117851648 Value2


In SQL Server Enterprise manager, I build the followng Query:

SELECT LBL_ID, LBL_VALUE FROM L_DATA WHERE (LBL_ID = 166955724) OR
(LBL_ID = 117851648)

It returns:

LBL_ID LBL_VALUE
166955724 Value1
117851648 Value2

This is the data I input for this stuff, this is what I expected to get.
Any reason why I am not getting it in the access query? Any help would be
much appreciated.

Another Note: If I put the SQL in a Pass Through Query, it works.
 
Are you sure that dbo_L_Data is linked to the same table in the same
database you are querying with the pass through? You don't by chance
have a test or development database that you were linked to.

Try deleting the link and relinking to the table and database.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
John,

Thanks for your response. It turned out that your suggestion to re-link the
table was the key. As you know, when you link to ODBC data source tables,
sometimes Access will ask you to identify a "Unique Identifier". (One or
more fields.) The concerned table actually has to use a combination of two
fields to create a uni1que identifier. I forgot that the first time I linked
it. At your suggestion, I re-linked it, and when I did, I realized what my
mistake was. This time I chose the two fields that make it a unique
identifier. It works fine now. Thanks a lot, sometimes all it takes is a
suggestion! You were very helful.
 
Back
Top