Sobolev spaces and function on boundary $\Omega \subset \mathbb{R}^n$ and a smooth boundary $Q=\partial \Omega$. $f,g \in C^{\infty}_0 (\mathbb{R}^n) $
$h$ be defined as $h =  \chi _{\Omega} f + \chi _{\mathbb{R}^n /\Omega}g$ in $\mathbb{R}^n$
I want to show:
$$h\in H^{1,2}(\mathbb{R}^n) \Leftrightarrow f=g$$ on $Q$.
Im also interested in the weak derivative of $h$.
Anyone has an idea how to show that?
 A: Thm: A function $u \in L^2(\Omega)$ is in $H^1(\Omega)$ if and only if it has a representative $\overline{u}$ that is absolutely continuous with respect to almost every line segment that is parallel to the coordinate axes and $\partial_i \overline{u} \in L^2(\Omega)$. 
The $\partial_i$'s in the theorem represent the classical partial derivatives. Moreover, the classical partial derivative of $\overline{u}$ agree almost everywhere with the weak derivatives of $u$.
References to this theorem are Leoni's book on Sobolev spaces and Evans' and Gariepy's book.
You can now use this theorem to argue that a necessary and sufficient condition for $h$ to be in $H^1$ is that $f = g$ on $Q$. You'll need one more ingredient: $w \colon [a,b] \to \mathbb{R}$ is absolutely continuous if and only if the classical derivative $w'$ exists almost everywhere, $w' \in L^1_{loc}$ and the fundamental theorem of calculus holds, i.e.
$$w(x) = w(a) + \int_a^xw'(t)\,dt$$ for all $x \in [a,b]$.

In reply to the comment: 
Let $\varphi \in C^{\infty}_0(\mathbb{R}^N)$. Then for $i = 1, \dots, N$ we have
$$
\int_{\mathbb{R}^N}h\partial_i\varphi = \int_{\Omega}f\partial_i\varphi + \int_{\mathbb{R}^N \setminus \Omega}g\partial_i\varphi = I + II
$$
By the divergence theorem
$$I = -\int_{\Omega}\partial_i f \varphi + \int_{Q}f\varphi \nu_i,$$ where $\nu_i$ is the $i$-th component of the exterior normal unit vector to $\Omega$. Perform a similar computation for $II$. Can you pick it up from here?
