SQL Server Mobile Bug?

We've migrated a .NET CF 1.0 App with SQL CE 2.0 to .NET CF 2.0 and SQL Server Mobile and we were wondering about the new behavior. A sample to reproduce:

create table persons ( id int identity primary key,
firstname nvarchar(100),
lastname nvarchar(100));

create table logins ( id int identity primary key,
personid int not null,
password nvarchar(100));

insert into persons(firstname, lastname) values ('Scott', 'Tiger');
insert into persons(firstname, lastname) values ('Bill', 'Gates');
insert into persons(firstname, lastname) values ('Test', 'Man');

insert into logins(personid, password) values (2, 'bill');
insert into logins(personid, password) values (1, 'tiger');
The Query

select p.firstname, p.lastname from persons p inner join logins l on p.id = l.personid

returns as expected

Scott Tiger
Bill Gates
But when I'm trying to sort the result with "order by p.lastname, p.firstname":

select p.firstname, p.lastname from persons p inner join logins l on p.id = l.personid order by p.lastname, p.firstname

I'm getting

Bill Gates
Bill Gates
Test Man
Test Man
Scott Tiger
Scott Tiger
I've tested with 3.0.5206.0 (included in VS 2005), 3.0.5207.0 (included in SQL Server 2005 Dev. Ed.) and 3.0.5214.0 (just released SQL Server Mobile SDK -http://www.microsoft.com/downloads/details.aspx?FamilyId=5BD8ABAA-5813-4DB3-B23A-24551DE2ECC1&displaylang=en
)

The bug also appears when I'm adding referential integrity between the two tables:

create table persons ( id int identity primary key,
firstname nvarchar(100),
lastname nvarchar(100));

create table logins ( id int identity primary key,
personid int references persons(id),
password nvarchar(100));
Can you confirm and how do I inform Microsoft?

[2090 byte] By [KlausPrückl] at [2008-2-8]
# 1
Thanks for the catch. This is a bug in our code. Here is the earlier report from another customer:

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=bd63c126-f6fd-41bb-a5a4-f4265847e3cc

This behavior is only when the INNER JOIN is performed on a non-indexed column.

Here is a work around: Please create an INDEX on the columns which are used in INNER JOIN.

In your case personid of logins table.

CREATE INDEX IndexLoginsPersonID ON logins (PERSONID);

I tried the same and found the results same in both cases (with and with out order by).

This would be fixed in our next version of SQL Mobile.

Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation

LaxmiNROMSFT at 2007-10-6 > top of Msdn Tech,SQL Server,SQL Server Compact Edition...
# 2
When will the new version be available?

Thanks,
Klaus Prückl

KlausPrückl at 2007-10-6 > top of Msdn Tech,SQL Server,SQL Server Compact Edition...
# 3
Hi,

We just released 3.0 version and next version is a long way ahead. So I recommend you going with the work around. But I would check if it is possible for the service pack.

Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation

LaxmiNROMSFT at 2007-10-6 > top of Msdn Tech,SQL Server,SQL Server Compact Edition...

SQL Server

Site Classified