Computed Column Problem

  • I have a strange problem. I have a computed column in a replicated table, the Formula is as follows: (isnull(hashbytes('SHA2_256',CONVERT([varchar](256),[AccrualReference],(0))),(0))) the column is also Persisted.

    This gets around a case sensitivity issue and is used as the Primary Key column, which works well.

    The problem is that this table is then replicated to another server. On the subscriber the value of this computed field is being returned as 0x00000000 for every row, so this must be the ISNULL function doing its job. But why? The AccrualReference is the true PrimaryKey and is never NULL.

    If I remove the computed specification and set the field up as varbinary(64) the value then gets replicated. This then means maintaining a different table schema for in excess of 500 tables.

    I won't go into the semantics of why we are doing this, as it is a long story.

  • SHA2_256 is supported on 2012 and greater. ARe you running 2012 and is your compatibility level 110 or more?

    Catch-all queries done right [/url]
    Gail Shaw's Performance Blog[/url]

  • I didn't think about it being a compatibility problem, you have hit the nail on the head. We are replicating from 2012 to 2008.

    Thank you for taking the time to reply.

    Tim

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply