Search code examples
c#sql-serverstringsqlclr

C# SQL CLR - convert SqlString to String


This works but I want to convert SqlString to String and do String.Length. If String.Length is e.g. 5, I want to display in cell (in table in SQL Server) e.g. Active, but if not, I want to display the current field value.

public class proveraMb
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlString matbr (SqlString ispravan)
    {
        SqlString i = ispravan;

        if (i == "ss")
            return i;
        else
            return "nije dobar";
    }
}

Solution

  • You just need to call the ToString() method

    Sample

    SqlString i = ispravan;
    string test = i.ToString();