3. Let $[x]$ denote the greatest integer not exceeding the real number $x$. The equation
$$
\lg ^{2} x-[\lg x]-2=0
$$
3. From $[\lg x] \leqslant \lg x$ we get $\lg ^{2} x-\lg x-2 \leqslant 0$ which means $-1 \leqslant \lg x \leqslant 2$

When $-1 \leqslant \lg x<0$, we have $[\lg x]=-1$, substituting into the original equation gives $\lg x= \pm 1$, but $\lg x=1$ is not valid, $\therefore \lg x=-1, x_{1}=\frac{1}{10}$.

When $0 \leqslant \lg x<1$, we have $[\lg x]=0$, substituting into the original equation gives $\lg x= \pm \sqrt{2}$, both are not valid.

When $1 \leqslant \lg x<2$, we have $[\lg x]=1$, substituting into the original equation gives $\lg x= \pm \sqrt{3}$, but $\lg x=-\sqrt{3}$ is not valid, $\therefore \lg x=\sqrt{3}, x_{2}=10^{\sqrt{3}}$.
When $\lg x=2$, we get $x_{3}=100$.
$\therefore$ The original equation has 3 real roots.