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
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;
}
}
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:
- Open Task Manager
- Switch to the Processes tab
- Find mcshield.exe
- Right-click → Set Priority → Normal
Happy system. Happy me.
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.
To find all rows that are in dbo.TABLE1 but not in dbo.TABLE2 using the SQL JOIN operator:
SELECT COUNT(*)
FROM dbo.TABLE1 t1 WITH (NOLOCK)
LEFT OUTER JOIN dbo.TABLE2 t2 WITH (NOLOCK)
ON t1.PrimaryKey = t2.PrimaryKey
WHERE t2.PrimaryKey IS NULL
I installed the SQL Server 2008 Feature Pack to get the DTS components for SQL Server Management Studio 2008. However, the IDE continued to error until I copied the following files from the SQL Server 2000 manager to the SQL 2008 Manager folders.
You need to have SQL 2000 Enterprise Manager installed on the same machine.
Copy Components into SQL Server 2005
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\semsfc.dll" "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\semsfc.dll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\sqlgui.dll" "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\sqlgui.dll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\sqlsvc.dll" "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\sqlsvc.dll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\Resources\1033\semsfc.rll" "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Resources\1033\semsfc.rll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\Resources\1033\sqlgui.rll" "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Resources\1033\sqlgui.rll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\Resources\1033\sqlsvc.rll" "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Resources\1033\sqlsvc.rll"
Copy Components into SQL Server 2008
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\semsfc.dll" "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\semsfc.dll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\sqlgui.dll" "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\sqlgui.dll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\sqlsvc.dll" "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\sqlsvc.dll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\Resources\1033\semsfc.rll" "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Resources\1033\semsfc.rll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\Resources\1033\sqlgui.rll" "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Resources\1033\sqlgui.rll"
copy /y "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn\Resources\1033\sqlsvc.rll" "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Resources\1033\sqlsvc.rll"
Do not do this:
if ("A,B,C,D,E".IndexOf(key) > -1)
{
// CODE REDACTED
}
If key is an empty string, the result is 0 and the code in the IF block is executed. This is probably not what you expected.
I have an application concept in my head and wanted to build it for Google AppEngine.
The AppEngine SDK is offered in two flavors: Python and Java. I wasn’t really sure which SDK to pick. Python has been supported since Day One – it has the most examples and the best API support. In addition, it includes the webapp framework and Django support.
I’ve picked Python as the implementation framework.
This post was created on a Slate PC – a Motion Computing LE1600 -running Windows 7 and "typed" using the handwriting recognition very very quickly :)
I AM Impressed!
These calls will retrieve DB2 system properties.
SELECT *
FROM TABLE(SYSPROC.ENV_GET_INST_INFO()) AS Instance_Info
GO
SELECT *
FROM TABLE(SYSPROC.ENV_GET_PROD_INFO()) AS Product_Info
GO
SELECT *
FROM TABLE(SYSPROC.ENV_GET_SYS_INFO()) AS System_Info
GO
Create a junction in Windows 7 using the MKLINK command.
mklink /j source-path target-path
As an example, create a junction called C:\Volatile that resides on the S: drive.
mklink /j C:\Volatile S:\Volatile
