Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Hashbyte in persisted computed column? Expand / Collapse
Author
Message
Posted Thursday, December 13, 2007 7:17 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, July 26, 2013 12:35 PM
Points: 61, Visits: 204
Hi,
I'm trying to create a persisted computed column using the hashbyte function. But when adding this column to my table I get a error message which says:
Computed column 'check' in table 'tbl_cons' cannot be persisted because the column is non-deterministic.

My Alter Statement looks like this:
Alter TAble tbl_cons Add [check]  AS (hashbytes('md5', isnull ([TICKER] ,'') + isnull ( convert(nvarchar, CPN) ,'')  + ... )

It builds a hash out of ca. 200 columns. AFAIK hashbytes is non-deterministic for NULL values, but as I'm using isnull() this can never happen.
Before hashbytes I used checksum, but there have been changes on the underlying columns which didn't change the checksum.
Any chance to make this column persisting?

Regards,

Jan
Post #432828
Posted Thursday, December 13, 2007 8:16 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 6:06 PM
Points: 7,116, Visits: 14,990
Something else is making it non-deterministic. I just tried using hashbytes of a single column in a persisted computed column, and it does work. Check for any other calls that might make it non-deterministic.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #432875
Posted Thursday, December 13, 2007 8:55 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, July 26, 2013 12:35 PM
Points: 61, Visits: 204
Hi Matt,
thanks for that hint, it seems that I'm getting this error if one of the used columns is datetime, although it is converted into nvarchar.
I'll try to find an workaround and post it.

Regards,

Jan
Post #432912
Posted Thursday, December 13, 2007 9:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 6:06 PM
Points: 7,116, Visits: 14,990
Keep in mind that getdate() is non-deterministic, so that if it happens to be using that your result will forever be non-deterministic.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #432922
Posted Thursday, December 13, 2007 9:29 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, July 26, 2013 12:35 PM
Points: 61, Visits: 204
Hi,
it seems that this error only occurs by converting datetime columns into a style which contains spaces. Using 126 as style (also tried 101 - 105) works fine, while using 106 produces this error message.

Update: This works, but it isn't possible to replicate this column because sql server says it is non-deterministic. I think this is a bug on SQL Server 2005, what do you guys think?

Regards,

Jan
Post #432938
Posted Thursday, July 25, 2013 5:47 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 4, 2014 9:15 AM
Points: 1,426, Visits: 332
This issue is resolved by installing SP1:

http://support.timextender.com/entries/20833882-Computed-column-deployment-error-on-SQL-Server-2005-SP1
Post #1477809
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse