shahjagat
asked on
SQl Random Number Generation and Audit Changes
Hello,
1) I am using the NewID() to generate the random numbers for one column in sql database table. Does it check for the uniqueness in the database table? This is how I am generating the random number and in the table the column's datatype is given as int.
ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT))
2) On my WebPage, if user edits something, I want to keep track of old data and new data as well. So, What I am doing is , I am just inserting a new record in to the table. Is there any other best way to do this? Something like audit, Which will have everything in it, like what was changed and when was it changed?
Thanks
1) I am using the NewID() to generate the random numbers for one column in sql database table. Does it check for the uniqueness in the database table? This is how I am generating the random number and in the table the column's datatype is given as int.
ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT))
2) On my WebPage, if user edits something, I want to keep track of old data and new data as well. So, What I am doing is , I am just inserting a new record in to the table. Is there any other best way to do this? Something like audit, Which will have everything in it, like what was changed and when was it changed?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT))
but you may get same numbers (low probability but possible)
use auto number... don't create random number...