Sql queries for updating column values Hot usan xxx
In this example we are going to create a table (to mimic a table that already exists), load 100,000 records and then alter the table to add the identity column with an increment of 1.
SQL Server parse and compile time: CPU time = 0 ms, elapsed time = 1 ms.
SQL Server parse and compile time: CPU time = 0 ms, elapsed time = 247 ms.
SQL Server Execution Times: CPU time = 0 ms, elapsed time = 1 ms. Scan count 1, logical reads 26384, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
We will follow the same hierarchy in the subsequent steps of this tip. Customer_data table which contains credit card details for customers.
Our task is to protect this data by encrypting the column, which contains the credit card number.
This doesn't mean that on your systems you won't possibly face the same issue, so to avoid having duplicate values Tillman and Steve have suggested these approaches.
I have a database table that has a lot of data already in the table and I need to add a new column to this table to include a new sequential number.
In addition to adding the column, I also need to populate the existing records with an incremental counter what options are there to do this?
If we compare the statistics time and statistics i/o from the the update with the identity column to this approach the overall number of logical reads is just about the same, but the overall duration is about 10 times faster doing the update versus having to maintain the identity value.
Let's say we want to increment by 10 instead of by 1.