• This design:

    CREATE TABLE #TestTb1 ([Sample_ID] VARCHAR(10), [P1] INT, [P2] INT, [P3] INT, [P4] INT)

    is going to bite you. I would strongly recommend not doing that. (I worked on even small databases in Ack!cess that were like this, and performance was abominable. If you create a union query, you may lose the benefits your indexing provides, so you'll get table scans every time you query anything. Performance killer.

    If you changed your structure to something like

    CREATE TABLE #TestTb1 ([Sample_ID] VARCHAR(10)

    , [TestID], [P1] INT)