Search code examples
sqlsql-serverstringselectnvarchar

Add \ to in a select query


I need help in sql please.

I have a nvarchar field called Users in which i store strings like this:

UAT\dabrego

this is the query:

Select IdentityName from Users

Ans i want to retrive the strings like this:

UAT\\dabrego


Solution

  • Select REPLACE(IdentityName, '\','\\') AS  IdentityName
    from [Users]