SQLTeam.com | Weblogs | Forums

Why result when select top 10 is different from same table?

I work on sql server 2012 I face issue when i select top 10 from table parts

it different part id when select top 10 * from same table

what I do as below :

 select top 10 * from parts.nop_part
    
 select top 10 partid from parts.nop_part

result first statement

 PartID    PartNumber    PartNumberNon    CompanyID
 10    THS6002CDWP    THS6002CDWP    1005070
 12    THS6002IDWP    THS6002IDWP    1005070
 13    THS6002IDWPR    THS6002IDWPR    1005070
 14    TLV6004IPWR    TLV6004IPWR    1005070
 15    TLV6002IDGKR    TLV6002IDGKR    1005070
 16    TLV6002IDGKT    TLV6002IDGKT    1005070
 17    TLV2369IDGKR    TLV2369IDGKR    1005070
 18    TLV6002IDR    TLV6002IDR    1005070
 19    TLV2369IDGKT    TLV2369IDGKT    1005070
 20    TLV2369IDR    TLV2369IDR    1005070

result of second statement :
partid

15
16
18
92692
10
12
13
1323975
18573944
18575053

why part id changed from first statement to second statement

although this is top 10

this is my question

TOP without an ORDER BY can return any 10 rows. SQL directly states that you should not assume a particular order of rows.

1 Like