Example 2 Let $[x]$ denote the greatest integer not greater than the real number $x$. The number of real roots of the equation $\lg ^{2} x-[\lg x]-2=0$ is $\qquad$
(1995, National High School Mathematics Competition)
Analysis: The difficulty of this problem lies in the uncertainty of $[\lg x]$. Since $[\lg x] \leqslant \lg x$, the original problem is first transformed into finding the values of $x$ that satisfy the inequality $\lg ^{2} x-\lg x-2 \leqslant 0$.
Solving this, we get $-1 \leqslant \lg x \leqslant 2$.
Therefore, the number of roots of the equation can be found by solving for $[\lg x]$ taking the values -1, 0, 1, 2, respectively, yielding the three roots as $x_{1}=\frac{1}{10}, x_{2}=10^{\sqrt{3}}, x_{3}=100$.