Later, a ninth person died at a local hospital, an immigration and customs spokesman said.
Thirty others were inside the trailer without air conditioning or water while outside temperatures hit 38C (110F).
Twenty were airlifted to hospital and eight more hospitalised by other means.
Police say they believe the incident is linked to people smuggling.
San Antonio is a few hours' drive from the border with Mexico and the US immigration department is trying to establish the victims' legal status.
Officials were brought to the trailer by a man who had approached an employee of the Walmart and asked for water.
The driver would be charged in connection with the "horrible tragedy", said San Antonio police chief William McManus in a press briefing.
He said the people ranged from school age to in their 30s.
Video footage from the store showed a number of vehicles arriving to pick up some of the survivors. Several others may have managed to escape on foot into the woods nearby.
"We're looking at a human trafficking crime this evening," Mr McManus added.
Local fire chief Charles Hood said the survivors had heart rates of over 130 beats per minute and were very hot to touch. In addition to the 20 people in a critical condition, eight others were taken to hospital in a less severe state.
The fire chief confirmed at least two of the victims were school-age children. Their condition is not clear.
"We're very fortunate that there weren't 38 of these people who were all locked inside this vehicle dead," he added.
The US attorney for the Western District of Texas, Richard Durbin, said the authorities were working to identify those responsible for the incident.
"These people were helpless in the hands of their transporters. Imagine their suffering, trapped in a stifling trailer in 100-plus degree heat," he said in a statement.
They were victims of "ruthless human smugglers indifferent to the wellbeing of their fragile cargo", he added.
Police in the US state of Texas have arrested a truck driver whose vehicle was found in a Walmart car park with eight people dead in the back of it, two of them children.