Friday 29 June 2012

Query to delete large sets of records

I have found it useful when doing deletes from table with a large number of rows to delete rows in batches of say 5000 or so (I usually test to see which value works the fastest, sometimes it's 5000 rows, sometimes 10,000, etc.).
This allows each delete operation to complete quickly, rather than waiting a long time for one statement to knock out 400 million records.
In SQL Server 2005, something like this should work

WHILE EXISTS ( SELECT 1 FROM EventLog WHERE EventLogid < 8700000000)
BEGIN
  DELETE TOP(5000) FROM EventLog WHERE EventLogid < 8700000000

END

Wednesday 27 June 2012

Add a second y axis to a chart in excel

Select the data from the table


Go to Insert chart.Select 2D bars


You will observe that count bars will be hidden because of the scale which is automatically set to adjust the high values of timespent.Therefore select red bars and change their style to line by



Change series chart type to Line


Go to layout (keep the line chart of timespent selected),Select Format selection and choose secondary axis



 Now the data will look like this


So you have two y axes corresponding to the same X axis data.Hope it helps you in analysing data.:)