What is imprecise column in SQL Server?

Creating index on computed column of type nvarchar raises following error:

Cannot create index or statistics ‘MyIndex’ on table ‘MyTable’ because
the computed column ‘MyColumn’ is imprecise and not persisted.
Consider removing column from index or statistics key or marking
computed column persisted.

  • Reference .NET Assembly from a SQL Server Stored procedure or function
  • SQL SERVER - Using DATEDIFF with subquery column
  • .Net SqlConnection, Server Authentication, and Certificate Pinning
  • Why does a Serializable Isolation level lead to deadlock and concurrency issues?
  • SQL Server CEILING of 100 = 101?
  • How to protect my SQL Server database?
  • What does imprecise column mean?

    UPDATE. The definition is following:

    alter table dbo.MyTable
        add [MyColumn] as dbo.MyDeterministicClrFunction(MyOtherColumn)
    go  
    create index MyIndex on dbo.MyTable(MyColumn)
    go
    

    UPDATE2. The MyDeterministicClrFunction is defined as following:

    [SqlFunction(IsDeterministic = true)]
    public static SqlString MyDeterministicClrFunction(SqlString input)
    {
        return input;
    }
    

    3 Solutions collect form web for “What is imprecise column in SQL Server?”

    Per MSDN, CLR Function columns must be persisted to be indexed:

    Any computed column that contains a common language runtime (CLR) expression must be deterministic and marked PERSISTED before the column can be indexed. CLR user-defined type expressions are allowed in computed column definitions. Computed columns whose type is a CLR user-defined type can be indexed as long as the type is comparable. For more information, see CLR User-Defined Types.

    Persist the column and I suspect it will work.

    From the SQL server documentation:

    Any float or real expression is considered imprecise and cannot be a
    key of an index; a float or real expression can be used in an indexed
    view but not as a key. This is true also for computed columns. Any
    function, expression, or user-defined function is considered imprecise
    if it contains any float or real expressions. This includes logical
    ones (comparisons).

    Have you tried:

    [SqlFunction(IsDeterministic=true, IsPrecise=true)]
    

    http://msdn.microsoft.com/en-us/library/orm-9780596101404-02-12.aspx

    http://msdn.microsoft.com/en-us/library/ms189292.aspx

    Sounds like the error message is misleading because CLR computed columns have to be persisted anyway (to be indexed).

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.