473,385 Members | 1,154 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,385 software developers and data experts.

Why Same query results in two different # in SQL Server vs MS Access

Hello,
I have one simple query joining two tables with left outer join on 3
fields and using MIN on two fields. These two tables have lot of data
about 3 mil in total. I am trying to migrate db from MS Access to SQL
2005. I get about 689000 rows in SQL Server, vs 863000 rows in MS
Access.

SELECT T1.[MON], T1.[ANUM], T2.[ANUM], MIN ( T1.[OCD]), MIN(T1.
[STATE]), T1.COUNT
FROM T1 INNER JOIN T2 ON T1.MON = T2.MON AND T1.[OCD] = T2.[OCD] AND
T1.[STATE] = T2.[STATE]
WHERE T1.[REASON] <'SOMETHING' AND T2.[REASON] <'SOMETHING'
GROUP BY T1.[MON], T1.[ANUM], T2.[ANUM], T1.COUNT
HAVING T1.[MON] <'-' AND T1.[ANUM] <'-'
I have about 30 queries to migrate and I am sort of stuck. Does any
one have any idea ?

Many thanks,
JB
Feb 20 '08 #1
2 2205
On 20 Feb, 19:42, dsdevonso...@gmail.com wrote:
Hello,
I have one simple query joining two tables with left outer join on 3
fields and using MIN on two fields. These two tables have lot of data
about 3 mil in total. I am trying to migrate db from MS Access to SQL
2005. I get about 689000 rows in SQL Server, vs 863000 rows in MS
Access.

SELECT T1.[MON], T1.[ANUM], T2.[ANUM], MIN ( T1.[OCD]), MIN(T1.
[STATE]), T1.COUNT

FROM T1 INNER JOIN T2 ON T1.MON = T2.MON AND T1.[OCD] = T2.[OCD] AND
T1.[STATE] = T2.[STATE]

WHERE T1.[REASON] <'SOMETHING' AND T2.[REASON] <'SOMETHING'

GROUP BY T1.[MON], T1.[ANUM], T2.[ANUM], T1.COUNT

HAVING T1.[MON] <'-' AND T1.[ANUM] <'-'

I have about 30 queries to migrate and I am sort of stuck. Does any
one have any idea ?

Many thanks,
JB
I had an issue on some machines where Access LEFT OUTER joins where
doing the same as INNER joins I had to upgrade the version of jet on
those machines. There was no error message.

can your fields like OCD contain NULLS, before changing config options
ANSI_NULLS etc etc.

try if its ACCEPTABLE to your query to cope with them..

e.g. in SQL Server do MIN(ISNULL(OCD,0))

or in Access MIN(NZ(OCD,0))

and see what you get - should be a quick and easy test. I cannot
remember but certain aggregate funcs in SQL omit null values depending
on config options..
Feb 21 '08 #2
On Feb 21, 8:39 am, Yitzak <terrysha...@yahoo.co.ukwrote:
On 20 Feb, 19:42, dsdevonso...@gmail.com wrote:
Hello,
I have one simple query joining two tables with left outer join on 3
fields and using MIN on two fields. These two tables have lot of data
about 3 mil in total. I am trying to migrate db from MS Access to SQL
2005. I get about 689000 rows in SQL Server, vs 863000 rows in MS
Access.
SELECT T1.[MON], T1.[ANUM], T2.[ANUM], MIN ( T1.[OCD]), MIN(T1.
[STATE]), T1.COUNT
FROM T1 INNER JOIN T2 ON T1.MON = T2.MON AND T1.[OCD] = T2.[OCD] AND
T1.[STATE] = T2.[STATE]
WHERE T1.[REASON] <'SOMETHING' AND T2.[REASON] <'SOMETHING'
GROUP BY T1.[MON], T1.[ANUM], T2.[ANUM], T1.COUNT
HAVING T1.[MON] <'-' AND T1.[ANUM] <'-'
I have about 30 queries to migrate and I am sort of stuck. Does any
one have any idea ?
Many thanks,
JB

I had an issue on some machines where Access LEFT OUTER joins where
doing the same as INNER joins I had to upgrade the version of jet on
those machines. There was no error message.

can your fields like OCD contain NULLS, before changing config options
ANSI_NULLS etc etc.

try if its ACCEPTABLE to your query to cope with them..

e.g. in SQL Server do MIN(ISNULL(OCD,0))

or in Access MIN(NZ(OCD,0))

and see what you get - should be a quick and easy test. I cannot
remember but certain aggregate funcs in SQL omit null values depending
on config options..

Hello everyone,
I had nulls in few fields, but I had specified same criteria in both
sql and access. Even with specifying conditions to take care of NULLs
in Access, the two queries gave me different results. So after I tried
all the options and no success, I started from scratch as IYLE
suggested, with one by one column in both sql and ms access and I am
now getting similar results. This was a weird exercise as still I am
not sure, what could have been wrong.

Many thanks,
JB
Feb 28 '08 #3

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
6
by: Steven D.Arnold | last post by:
I have a query which does not use column indexes that it should use. I have discovered some interesting behaviors of Postgres which may indicate a bug in the database's query planning. Take a...
5
by: sql-db2-dba | last post by:
We have DB2 UDB v8.1 fixpak3 on AIX 5. Production and Development configuarations (at least for DB2) are identical albeit production is a 2-way server while development has only one processor....
2
by: Mattyboy | last post by:
Guys I have built a database with saved queries that runs fine in Access but when I call it from the web using ASP, an exception occurs. I have tried multiple ways of testing the databases with...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
24
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
3
by: Bill Hutchison | last post by:
I have a query that returns different results (3508 rows for snapshot, 6288 for dynaset) and that is the only thing I change to get the different results. When I try to make a table from the...
4
by: dsdevonsomer | last post by:
Hello, I have one simple query joining two tables with left outer join on 3 fields and using MIN on two fields. These two tables have lot of data about 3 mil in total. I am trying to migrate db...
3
by: Kunal Desale | last post by:
Hello, I am migrating access queries to SQL Server 2005 Queries. My Access Query Is: SELECT qtrade.intordreftrim AS Expr1, qtrade.extordreftrim AS Expr2, qtrade.intinvreftrim AS Expr3,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.