If Sandworm's last ability resolves but doesn't destroy the target land (probably because the land had indestructible), the target land's controller still gets to search for a basic land card.

Artwork
Loading artwork…
Sandworm
Final Fantasy · #155 · EN
Nonfoil—Foil—
Card rules
Haste
When this creature enters, destroy target land. Its controller may search their library for a basic land card, put it onto the battlefield tapped, then shuffle.
5/4
Uncommon · Illustrated by Awanqi (Angela Wang)
Format legality
Alchemy Legal
Brawl Legal
Commander Legal
Competitive Brawl Legal
Duel Legal
Future Legal
Gladiator Legal
Historic Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Pioneer Legal
Standard Legal
Standard Brawl Legal
Timeless Legal
Vintage Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Penny Not Legal
PreDH Not Legal
Premodern Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
If the target land is an illegal target when Sandworm's last ability tries to resolve, it won't resolve and none of its effects will happen. The target land's controller won't search for a basic land card.