Timatic says:
Visa required, except for Passengers transiting through
Bangkok (BKK) with a confirmed onward ticket for a flight to a
third country within 12 hours. They must stay in the
international transit area of the airport and have documents
required for the next destination.
This TWOV facility does not apply to passengers traveling
on Angkor Air (K6), Beijing Capital Airlines (JD), Business
Air (8B), Cebu Pacific (5J), Eaststar Jet (ZE), Golden
Myanmar Airlines (Y5), Indigo (6E), Jeju Air (7C), Jet Asia
Airways (JF), Jetstar (JQ), Jetstar Pacific (BL), Jin Air
(LJ), JuneYao Airlines (HO), Lao Central Airlines (LF),
Mandara Airlines (RI), Norwegian Air (DY), Okay Airways
BK), Orient Thai Airlines (OX), Regent Air (RX), Scoot
(TR), Shandong Airlines (SC), Shanghai Airlines (FM),
Shenzhen Airlines (ZH), Siberia Airlines (S7), Sichuan
Airlines (3U), South East Asian Airlines (DG), Spice Jet
(SG), Thai Smile Airlines (WE), Tianjin Airlines (GS),
Trans Aero (UN), Turkmenistan Airlines (T5), T'way Airlines
(TW), Ural Airlines (U6) and VietJet Air (VJ).
So the first question is: Are you travelling on any of those airlines? Then you will need a second visa.
If not, then will you be able to stay in the international transit area? If you are travelling with checked luggage, the answer is most probably no. Just as an example, Bangkok Airways' policy is that
When passenger travel with two separate tickets, Bangkok Airways will no longer through-check passenger and bags to the end destinations on the secondary separate ticket.
Still, you may check with the first airline whether they have an interline agreement with Thai Airways, even if the flights are on two separate tickets.
Finally, what if you're not travelling on any of the above airlines and without checked luggage? Well, I'm not sure. One website explains that
Yes – we tried the obvious! Even with no checked luggage and an onward boarding pass for flight #2 ready in hand, you are still not allowed to transit in Bangkok. No matter what, you have to exit through baggage claim in Bangkok and proceed through departures upstairs. Don’t blame the messenger!
but it's not clear for which airlines this applies. On the other hand, Thai Airways has a transfer counter and what would that be good for if passengers had to exit the transit area anyways? So in this case I'd recommend contacting Thai Airways and asking them whether you'll be eligible to use their transfer counter to get your onward boarding pass and not leave the transit area.