Example 2 Given that $x$ is an angle in the second quadrant, and $\sin x + \cos x = a, (|a| \neq 1)$, find the values of the following expressions:
(1) $\operatorname{tg} x - \operatorname{ctg} x$;
(2) $\sqrt{\frac{1-\sin x}{1+\sin x}} + \sqrt{\frac{1-\cos x}{1+\cos x}}$.
(1) $\operatorname{tg} x-\operatorname{ctg} x=\frac{(\sin x-\cos x)(\sin x+\cos x)}{\sin x \cos x}$.
Given $\sin x+\cos x=\hat{u}$, we have $1+2 \sin x \cos x=a^{2}$, which implies $\sin x \cos x=\frac{a^{2}-1}{2}$. Therefore, $(\sin x-\cos x)^{2}=2-a^{2}$.
Since $x$ is in the second quadrant, $\sin x-\cos x=\sqrt{2-a^{2}}$, thus,
$$
\operatorname{tg} x-\operatorname{ctg} x=\frac{2 a \sqrt{2-a^{2}}}{a^{2}-1}
$$
(2) 
$$
\begin{aligned}
& \sqrt{\frac{1-\sin x}{1+\sin x}}+\sqrt{\frac{1-\cos x}{1+\cos x}}=\frac{1-\sin x}{-\cos x}+\frac{1-\cos x}{\sin x} \\
= & \frac{(\sin x-\cos x)(\sin x+\cos x+1)}{\sin x \cos x}=\frac{2 \sqrt{2-a^{2}}}{a+1} .
\end{aligned}
$$