Sandworm is likely another iteration of Caterkiller (except in Sonic the Hedgehog 4: Episode 2), which was featured in the original Sonic the Hedgehog. Sandworm even uses the same sprites as Caterkiller. The only differences between these two Badniks is their color scheme. The main colors of Sandworm are blue, yellow, orange and gray. Since Sonic Colors, Sandworm's spikes are missing from its body.
Sandworm is only ever found burrowing around in quicksand pools in both acts of the zone. When burrowing, the displaced sand can be seen above them, creating a sort of ripple effect that shows roughly where they are. After a few seconds, they will stop and jump out in an arcing trajectory to another point in the sand. Like previous generations of Caterkiller, the only weak point is its head, as the rest of it is covered in spikes that will harm the player if touched.
The player should be particularly vary about falling off when riding blocks atop rollers over quicksand pools, because there is usually a pair of Sandworms in the sand below. They can be defeated whilst they are in the air, but it is difficult to do so, especially when two of them jump out at the same time, and are probably best left alone.
Sonic & Knuckles
Sandworm first appears in Sonic & Knuckles, sneaking under the quicksand in Sandopolis Zone. It attacks by jumping in and out of the zone's quicksand pools. Its physical appearance is similar to Caterkiller. The player can defeat Sandworm by hitting its head with a Spin Jump.
Sandworm returns in the Wii version of Sonic Colors, but with a different behavior. Unlike in Sonic & Knuckles, they do not jump around; instead, they emerge from holes in the ground and fire energy balls at the player. Sandworms only appear in the Asteroid Coaster, as well as certain levels in Game Land.
Sandworm returns yet again in Sonic Generations, making an appearance in Planet Wisp. Their behavior is exactly the same as it was in Sonic Colors.
Sonic Lost World
Sandworm appears once more in the Nintendo 3DS version of Sonic Lost World. During the game, it turns out that Badniks, Sandworms included, got hijacked by the Deadly Six. In the game, these Badniks can be found at Windy Hill and while having their cartoon-like design from Sonic & Knuckles, these Badniks are now more larger and seem to feature sparkling antennae this time.
It is also one of Badnik variants in the game, that have to be hit three times at its head in order to destroy it and progress through the stage. When the Sandworm's antennae sparkles, it will smash its head towards the player. This makes the Badnik dizzy giving the player the opportunity to hit them once.
Appearances in Other Media
Sonic the Comic
Sandworm appears in Sonic the Comicissue 47's story Mystery of the Sandopolis Zone, a loose adaption of Sonic & Knuckles. At one point in the story, Sandworm surprises Sonic and tries to ambush him, but he manages to defeat it.
Sonic the Comic's issue 126 story Desert Fox features a different model of Sandworm which is larger, green and equipped with laser blasters on both sides of its head. In the story, Sandworm attacks Tails and Willie Waddle at Scorchio Zone. Willie, a comedian, tells the Sandworm a joke, distracting it and allowing Tails to defeat it.
Jazwares had made several figures of characters from the Sonic franchise due to the announcement of Sonic Generations. There was a Modern Tails figure packaged along with a blue/gray Sandworm figure.
In Sonic 3D Blast, there is an unnamed caterpillar-type badnik that appears in the Green Grove Zone and attacks like Sandworm. However, these Badniks are purple. Due to its coloring, it is possible that it may be a Caterkiller. Incidentally, they may be considered the same Badnik in Japan.
The Sandworm in the 3DS version of Sonic Lost World acts in a very similar way to the version of the Pokey enemy from the Super Mario Galaxy series, sharing attack patterns, defeat methods, and purpose of blocking paths.