Can an analytic variety extend along a codimension 2 subvariety?

Let $X$ be a smooth, connected, complex analytic variety, and $Y\subset X$ a closed, analytic subvariety of codimension at least 2. Now let $V\subset X\backslash Y$ be a closed, analytic subvariety. Is the closure $\bar{V}$ of $V$ in $X$ also analytic?

Motivation: In the case where $X$ is a surface, this seems to follow from Riemanns extension theorem, and perhaps it can even be proven this way. But it'd be nice if there were a reference (or if I'm missing something and this is false in general!)

Thanks!

• Perfect, thanks! This theorem (rightly) says that I need to assume that $V$ is of dimension larger than $Y$, otherwise i could take for example $X=\mathbb{P}^1, Y=\{0\}, V=\cup_n \{\frac1n\}$. If I assume $V$ is connected, can I remove the restrictions on dimension? Feb 10, 2018 at 22:33
• You could take $X=\mathbb{P}^1\times\mathbb{C}$, $Y=\{0\}\times \mathbb{C}$, and $V=((\cup_n \{\frac{1}{n}\})\times\mathbb{C})\cup ((\mathbb{P}^1\setminus\{0\})\times\{1\})$. $V$ is connected. Feb 10, 2018 at 22:59
• Or, if you want $V$ irreducible, take $X=\mathbb{C}^2$, $Y=\{0\}\times\mathbb{C}$, and $V=\{ (z,\exp(\frac{1}{z}))\in \mathbb{C}^* \times \mathbb{C} \mid z\in\mathbb{C}^* \}$. Feb 10, 2018 at 23:06
• Yeah I meant irreducible. In the second case, $Y$ doesn't satisfy my initial assumption of codimension at least 2 (this was sort of the motivation). Of course thats sort of a moot point cause you could just embed the whole thing in a bigger space eh. Ok, thanks for your help. I'll consolidate my thoughts and maybe post more later. Feb 10, 2018 at 23:16
• Oh yes, you can cross everything by $\mathbb{C}$ and obtain higher codim, as you say. Feb 10, 2018 at 23:18