DB2 TRUNCATE Clause

tech — tags: — rohand @ February 9, 2011 12:15 AM

The equivalent of the SQL Server TRUNCATE clause for DB2 v8 is

ALTER TABLE {TABLE-NAME} ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE

COUNT(*) All DB2 Tables

tech — tags: , — rohand @ August 13, 2010 9:37 AM

Here’s a succinct way of generating SELECT COUNT(*) against all tables in a DB2 database.

SELECT 'SELECT COUNT(*) AS COUNT_' || TABLE_NAME ||
' FROM ' || TABLE_SCHEMA || '.' || TABLE_NAME
FROM sysibm.TABLES
ORDER BY TABLE_NAME 

This returns output like the following:

SELECT COUNT(*) AS COUNT_ADVISE_INDEX FROM DB2INST.ADVISE_INDEX
SELECT COUNT(*) AS COUNT_ADVISE_WORKLOAD FROM DB2INST.ADVISE_WORKLOAD

Resize an Image in C#

tech — tags: , — rohand @ June 3, 2010 11:46 AM

This function will let you resize an image in C#.

public static Bitmap Resize(Bitmap original,
                        int width, int height)
{
  Bitmap bitmap = new Bitmap(width, height);

  using (Graphics gfx = Graphics.FromImage(bitmap))
  {
    gfx.InterpolationMode
            = Drawing2D.InterpolationMode.HighQualityBicubic;
    gfx.SmoothingMode
            = Drawing2D.SmoothingMode.HighQuality;
    gfx.PixelOffsetMode
            = Drawing2D.PixelOffsetMode.HighQuality;
    gfx.CompositingQuality
            = Drawing2D.CompositingQuality.HighQuality;

    gfx.DrawImage(original, 0, 0, width, height);

    return bitmap;
  }
}

Why is mcshield.exe Running with High Priority?

tech — tags: , — rohand @ April 25, 2010 2:13 AM

After weeks of putting up with significant disk activity and system slowness, I finally noticed that the McAfee anti-virus On Access Scanner process – mcshield.exe – was running as a High Priority process in Task Manager.

The fix was simple:

  1. Open Task Manager
  2. Switch to the Processes tab
  3. Find mcshield.exe
  4. Right-click → Set Priority → Normal

Task Manager - mcshield.exe

Happy system. Happy me.

List Stored Procedures with Contents in SQL Server

tech — tags: , — rohand @ April 7, 2010 8:47 AM

I needed to get a list of all stored procedures that accessed a specific column in a table. Some stored procedures generated dynamic SQL statements so the View Dependencies feature was not guaranteed to get me the full list.

This query lets me retrieve the name and body of all stored procedures in a database. Adding the filter to look for the specific column is relatively simple.

SELECT              o.Name AS SpName, c.Text AS SpBody
FROM                syscomments c WITH (NOLOCK)
JOIN                sysobjects o WITH (NOLOCK)
ON                  c.ID = o.ID
AND                 o.Type = 'P'        -- Only stored procedures
ORDER BY            o.Name

This query is for SQL Server 2005 but should work across all versions.

« Previous PageNext Page »
©2012 appytizers. All rights reserved.