I have the following CLR function:
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString PrintText(SqlString text)
{
// Put your code here
return new SqlString(text.Value);
}
And I want to get an enter symbol when passing
'\r\n'
to it. But insteat I get
'\r\n'
Could you please tell me what's wrong with this code.
Thank you.
In T-SQL you don’t write a line break as
\r\n. Instead you just use a line break:If you pass a string with
\r\nto the C# code, nothing magical happens, it doesn’t automatically get converted. The backslash character is just a character like any other. It’s when you use the backslash in a literal string in the code that the compiler uses it as an escape code, and puts the control characters in the actual string.