You are currently browsing the Blog weblog archives for March, 2008.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| « Feb | Apr » | |||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
- IIS (1)
- Open Source (1)
- Performance (3)
- Personal (2)
- Powershell (1)
- SQL (1)
- SQL Server (20)
- T-SQL (14)
- Uncategorized (6)
- Utilities (4)
- Windows OS (13)
- 23. August 2010: Alert for long-running SQL datbase backups
- 7. April 2010: Learning SMO & Powershell
- 25. February 2010: SQL Generators for moving database files
- 28. January 2010: Index to Filegroup mapping
- 20. January 2010: PowerShell Script to Clean Up Old Files Based on Age
- 7. January 2010: Quick & Dirty way to identify orphan files
- 29. July 2009: Trigger Mass Enable / Disable
- 29. June 2009: Moving Master and Resource databases
- 11. June 2009: Quick and Dirty CSV import to SQL Server
- 2. February 2009: Getting data file space usage
Archive for March 2008
Using Diskpart to Align a Windows Disk Partition
31. March 2008 by Bennett.
There is an EMC whitepaper titled Using diskpar and diskpart to align partitions on Windows Basic and Dynamic Disks. This paper describes how legacy Windows issues cause a single disk I/O to span multiple tracks. This puts an unnecessary load on the SAN and reduces performance. The fix is to align the partition. Below is a sample session using the DISKPART utility. Comments are in red.
Invoke Diskpart
C:\>diskpart
Microsoft DiskPart version 5.2.3790.3959
Copyright (C) 1999-2001 Microsoft Corporation.
On computer: MYTESTBOX
You must select the disk to act on
DISKPART> select disk 5
Disk 5 is now the selected disk.
Create a partition using the EMC-recommended alignment offset
DISKPART> create partition primary align=64
DiskPart succeeded in creating the specified partition.
Select the partition / volume that you just created
DISKPART> select volume=0
Volume 0 is the selected volume.
Assign a drive letter
DISKPART> assign letter=o
DiskPart successfully assigned the drive letter or mount point.
Exit Diskpart
DISKPART> exit
Leaving DiskPart…
C:\>
You can now use the disk management MMC to format the partition
Posted in Windows OS, Performance | Print | 4 Comments »
MD5 Hash Utilities
30. March 2008 by Bennett.
FCIV.EXE is a handy little utility to snap a MD5 hash of a single file or multiple files. Optionally it can recurse directories and produce XML output. http://support.microsoft.com/kb/841290
MD5SUM.EXE is a more commonly used utility that runs on a number of different platforms. A good Wikipedia article with links can be found here and a Win32 binary can be found here.
Posted in Utilities | Print | No Comments »
Simple SQL Server Log Filter / Review Script
28. March 2008 by Bennett.
Here’s a very basic log filtering /review script that you can run on a daily basis to review your SQL Server logs. It shows the last two days of log entries filtering out logon and backup entries.
– daily log review script
SET nocount ON
CREATE TABLE #Errors
(
LogDate DateTime,
ProcessInfo NVARCHAR(40),
ErrorText NVARCHAR(2048)
)
INSERT INTO #Errors
EXEC master..sp_readerrorlog -1
SELECT * FROM #Errors
WHERE DATEDIFF(DAY, LogDate, GETDATE())<2
AND ProcessInfo <> ‘Logon’
AND ProcessInfo <> ‘Backup’
DROP TABLE #Errors
I’m currently cooking up some VBScript to filter and e-mail log entries on a daily basis. I’ll publish that soon.
Posted in T-SQL | Print | No Comments »
Basic Database Inventory Script
4. March 2008 by admin.
/*
Name: Inventory.sql
Description: Second stab at inventory using systables
Author: Bennett Scharf
Compatibility: SQL Server 2005
*/
USE master
CREATE TABLE #tempresults
(
[name] sysname,
db_size NVARCHAR(13),
[owner] sysname,
[dbid] smallint,
created NVARCHAR(11),
[status] NVARCHAR(600),
compatibility_level tinyint
)
CREATE TABLE #tempresults2
(
database_name NVARCHAR(128),
backup_start_date datetime
)
INSERT INTO #tempresults
EXEC sp_helpdb
INSERT INTO #tempresults2
SELECT database_name, backup_start_date
FROM msdb.dbo.backupset AS b1
WHERE backup_start_date =
(
SELECT MAX(backup_start_date)
FROM msdb.dbo.backupset AS b2
WHERE b1.database_name = b2.database_name
AND type = ‘D’
)
SELECT db.name, tr.db_size, db.compatibility_level,is_auto_shrink_on,
state_desc, recovery_model_desc, page_verify_option_desc,
tr2.backup_start_date AS ‘last backup’
FROM sys.databases db
JOIN #tempresults tr
ON db.name =tr.name
LEFT OUTER JOIN #tempresults2 tr2
ON db.name = tr2.database_name
WHERE db.database_id >4 –This clause will exclude system DBs,master, model, msdb, and tempdb
ORDER BY db.name
DROP TABLE #tempresults
DROP TABLE #tempresults2
Posted in SQL Server | Print | No Comments »
Starting Windows Performance Logging at boot time
3. March 2008 by Bennett.
Performance logging will not start on its own at boot time. Here’s how to get around that problem.
-
Applies to: W2k3, XP
- Using the Performance MMC, create a set of counter logs.
- Use a specific name to save the settings, e.g., SQLPERF.
- At the command prompt, try starting and stopping performance logging using the logman.exe utility:
- logman start sqlperf
- logman stop sqlperf
- Set the Windows registry to automatically start performance counters at system startup
- Open the Registry Editor, regedit.exe.
- Navigate to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
- Add a string value. A good name would be logman.
- Set the value equal to logman start sqlperf (or the command in step 4.a. that successfully started performance logging).
References:
Posted in Windows OS, Performance | Print | No Comments »