Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8702569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:41:05+00:00 2026-06-13T02:41:05+00:00

I have two tables defined for actual and expected with exactly the same schema.

  • 0

I have two tables defined for actual and expected with exactly the same schema. I insert two rows into the expected table with say Ids of 2, 1.

I run

INSERT INTO actual EXEC tSQLt.ResultSetFilter 1, '{statement}'

to populate the actual then

EXEC tSQLt.AssertEqualsTable @expected = 'expected' , @actual = 'actual'

to compare the results.

Even though the data is in a different order (Ids are 1, 2 in the actual), the test passes.

I confirmed that the data was different by adding SELECT * FROM actual and SELECT * FROM expected in the test and running the test on its own with tSQLt.Run ‘{test name}’.

Does anyone know if this is a known bug? Apparently it is supposed to check per row so the ordering should be checked. All the other columns are NULL that are returned it is just the ID column that contains a value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:41:07+00:00Added an answer on June 13, 2026 at 2:41 am

    Unless an order by clause is specified in the select statement, the order isn’t guaranteed by SQL server (see the top bullet point at this MSDN page) – although in practice it is often ordered as you might expect.

    Because of this, I believe that tSQLt looking for non-identical and identical rows makes sense – but checking the order doesn’t – otherwise the answer could change at the whim of SQL server and the test would be meaningless (and worse – intermittently failing!). The tSQLt user guide on AssertEqualsTable states that it checks the content of the table, but not that it checks the ordering therein. What leads you to conclude that the order should be being checked as well? I couldn’t find mention of it.

    If you need the order to be checked, you could insert both expected and actual results into a temporary table with an identity column (or use ROW_NUMBER) and check the resultant table – if the order is different then the identity cols would be different.

    There is a similar method documented here on Greg M Lucas’ blog.

    Relying on the order returned from the table without an order by clause is not recommended (MSDN link) – so I’d suggest including one in your application’s call to the statement, or if an SP within it if the order of returned rows is important.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables A and B as defined bellow. create table A (
I have two tables defined as such: CREATE TABLE [SomeTable] ( [PrincipalID] [int] IDENTITY(1,1)
I have the following two tables defined... CREATE TABLE [LogLevel] ( [Id] int primary
I have two tables and I'm looking for the rows in one table where
I have two tables, lets say table1 and table2 with common columns, id and
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables, a user table and a application table: User id username
I have two tables as defined below: EMAILS ID SUBJECT BODY 1 Test1 blah

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.