I need a SQL function or query that can escape '\' (backslash) but only odd numbers of '\' (backslashes) from string. 

For example:

```
DECLARE @str nvarchar(max) ='abc\df\\gh\\\eg\\\\yu'

```

I am using the SQL `Replace` function to escape the backslash (`\`) like this:

```
@str  = Replace(@str,'\','\\')

```

But the problem is it will replace the even numbers of sub strings too. But I only need it should replace only even number of sub strings having '\' from string.