2. Function
$$
y=\sin ^{2} x+\sin x \cdot \cos x-2 \cos ^{2} x
$$

The range of the function is . $\qquad$
2. $\left[-\frac{\sqrt{10}+1}{2}, \frac{\sqrt{10}-1}{2}\right]$.

From the problem, we have
$$
\begin{aligned}
y & =\frac{1-\cos 2 x}{2}+\frac{1}{2} \sin 2 x-(\cos 2 x+1) \\
& =\frac{1}{2}(\sin 2 x-3 \cos 2 x)-\frac{1}{2} \\
& =\frac{\sqrt{10}}{2} \sin (2 x-\varphi)-\frac{1}{2},
\end{aligned}
$$

where $\varphi \in\left(0, \frac{\pi}{2}\right)$, and $\tan \varphi=3$.
Therefore, the range of the function is
$$
\left[-\frac{\sqrt{10}+1}{2}, \frac{\sqrt{10}-1}{2}\right] \text {. }
$$