I'm creating a checksum column in a table that is to be calculated over several columns within the table.
One of the columns to be included in the checksum formula has a data type ntext.
But on trying to complete this new table design (or similarly using alter table in QA) - both return an error stating that the data type is invalid for the checksum function.
This happens for both ntext and text data types.
Can anyone tell me if there is a way round this without having to change the data type - or the valid data types that can be used for the checksum funciton?
Also reasons why would be helpful!
Thanksplease ignore - http://www.dbforums.com/t989557.html shows this not to be possible...
nevermind|||you might want to try something like so:
SELECT checksum(col1,col2,CAST(CAST(col3 as varchar(1)) as int))
FROM testTable
I am not sure if this totally works. Text and Ntext are meant to hold large amounts of text data like notes field in a customer service application. There is no implicit data conversion between int and ntext\text in sql server because that is just one of the rules and it would'nt make much since do so. To tell the truth it sounds like your problem is a design issue. However you can explicitly convert data types as shown above but please keep in mind if you try to cast character data in col3 above to an int, you will recieve an error. So you might have to add an IsNumeric in there as well.|||CHECKSUM works with non-numeric data, so there is no need to recast as INT in your formula.
Though I'm still not sure that is going to give him what he needs...|||Why are you doing this? To enforce data integrity upon INSERT/UPDATE? Or to support some business rule? Either way you're already using a database, so the answer should be in design, not checksum-based tricks.|||hey trotsky!!
calm down.|||I'd love to hear the reason behind this... I can't for the life of me figure out why you might want/need to do it. I'm also with rdjabarov, and think that this smells very strongly of a high GQ (geek quotient) workaround for a case of poor relational design!
-PatP|||that's twice that you have agreed with RDjabarov.
hmmmmmmm is the feud over?
:D|||Feud? Did I miss a meeting?
-PatP|||must have been the coma. when i first go here you guys would go at it like turtles and bunnies.
No comments:
Post a Comment