Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


SQl Random Number Generation and Audit Changes

Posted on 2012-03-15
Medium Priority
Last Modified: 2012-03-15

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.


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?

Question by:shahjagat
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 70

Accepted Solution

Scott Pletcher earned 1000 total points
ID: 37726073
>> Does it check for the uniqueness in the database table? <<

Not unless you explicitly create a constraint or an index.  SQL does not by default check any column for uniqueness.

>> Which will have everything in it, like what was changed and when was it changed? <<

In SQL 2008 you can use Change Data Capture (cdc).
LVL 59

Expert Comment

ID: 37726123
this is fine


but you may get same numbers (low probability but possible)

use auto number... don't create random number...

Author Comment

ID: 37726919

Thanks for the Information. I tried using the CDC to track all the changes. After i enabled the CDC, i made some changes and i am having a problem when i am checking the logs. I posted a question. Can you see the link below.


Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question