SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Hashbyte in persisted computed column?


Hashbyte in persisted computed column?

Author
Message
Jan Wagner-460740
Jan Wagner-460740
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 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
Matt Miller (4)
Matt Miller (4)
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12645 Visits: 18584
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?
Jan Wagner-460740
Jan Wagner-460740
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 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
Matt Miller (4)
Matt Miller (4)
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12645 Visits: 18584
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?
Jan Wagner-460740
Jan Wagner-460740
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 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
Ric Sierra
Ric Sierra
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1487 Visits: 342
This issue is resolved by installing SP1:

http://support.timextender.com/entries/20833882-Computed-column-deployment-error-on-SQL-Server-2005-SP1
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search