Skip to main content

Posts

Showing posts from 2009

VS 2003 Find in Files

As anyone running Windows Vista will probably have noticed, the Find in Files feature hangs when running Visual Studio 2003 on Vista.To resolve this issue:Right-click the shortcut you use to launch Visual Studio .NET 2003Select the Compatibility tab.Check “Disable Visual Styles”Click OKLaunch VS 2003 – the Find in Files feature will work.

Reorganize files before releasing unused space

OK, what does it actually mean!

When shrinking a database in SQL you are presented with the option “Reorganize files before releasing unused space. Selecting this option may affect performance.”

If ticked it is the equivalent of running DBCC SHRINKDATABASE with a target_percent set, if it is unticked it is the equivalent of DBCC SHRINKDATABASE with the TRUNCATEONLY option.

Ticking the box may affect performance while shrinking the database so it may take longer BUT it will not affect the performance of the database once shrunk.

Improve SQL Server delete performance with views

The SQL Server development customer advisory team met with the MySpace database to team to tackle any pain points with their use of SQL Server. Fortunately one of the key points was an issue I am currently battling with: efficient ordered deletes on large quantities of data. They have identified a potential improvement creating a view and then deleting from within that view rather than deleting directly from the table. As MySpace are dealing with huge volumes of data and it works for them it has to be worth incorporating into any deletion plan.
This approach also provides an excellent way for deleting the top x records from a table.
Essentially:
create view v1 as (select top (10000) * from t1 order by a)
delete from v1
drop view v1

Full details from LuborK here >>

It is also worth considering disabling any indexes related to the table you are deleting from as described here.

How to enable and disable indexes

Whilst working to speed up a delete statement on a table of 6000000+ records it proved efficient to disable the table indexes, run the delete statement then enable the indexes again. If the indexes are left enabled there is a large overhead in rebuilding the indexes for each record that is deleted from the target table.Disable an index:alter index <<index name>> on <<table name>> disableEnable an index:alter index <<index name>> on <<table name>> rebuildPlease be aware the ALTER INDEX command is only available in SQL Server 2005 and above. Also, SQL Server Management Studio doesn’t show the disabled status of an index within the main view so it is possible to disable an index and leave it disabled without realising.More details on this from Decipher Info Sys

Acrobat.com Features

Features
Acrobat.com includes an online PDF converter so you can easily create Adobe® PDF documents from your existing files in Microsoft® Word, Excel®, PowerPoint®, and many other applications.

View and print PDF files across platforms that look exactly like the original documents regardless of the application used to create them.

Individuals, businesses and government agencies around the world trust and rely on PDF to communicate their ideas and vision.
https://acrobat.com/

T-SQL month name from month index

How to display a month name from an input of a month index (i.e. 1-12). The script below will return the month name for a given month index.DECLARE @MonthID intSET @MonthID = 5SELECT DateName(month, convert(datetime, '2009-' + cast(@MonthID as varchar) + '-01', 120))@MonthID could be any integer I have only declared a new variable here for completeness.

SQL Server Set Identity Seed

DBCC CHECKIDENT (table_name, RESEED, new_reseed_value)

E.g.
DBCC CHECKIDENT (Customers, RESEED, 2000)

From Microsoft: Checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new current identity value for the identity column.

Full article: http://technet.microsoft.com/en-us/library/ms176057.aspx

IIS Change the key length for an SSL renewal

*** IIS 6 ***

When applying for an SSL certificate renewal and the old certificate uses a 512 bit key length you may receive the following error: "The CSR you submitted has a 512 bit key size. We do not allow SSL Web Server certificate issued with a CSR less than 1024 bits."

There is no way within IIS to change the key length but the workaround is as follows:

1. Create a new website under IIS. Make sure the website is stopped.
2. Edit the new site.
3. Select the "Directory Security" tab.
4. Click "Server Certificate"
5. Click "Next"
6. Select "Create a new certificate"
7. Click "Next"
8. Select "Prepare the request now, but send it later".
9. Click "Next"
10. Enter a name for the new request and select a bit length of 1024.
11. Click "Next".
12. Enter the organisation name and organisational unit for the website you are attempting to renew.
13. Click "Next".
14. Enter the exact domain name for the webs…

Serving FLV video files from an MS server

When serving .flv files off of a Windows Server 2003 (or any other Windows server I would imagine) requires setting up the MIME type on the server first (it isn't one of the native MIME types on MS servers).

1) Select the site to configure in IIS, right click and select "Properties"
2) Under the "HTTP Headers" Tab, click "MIME Types" under the MIME types section
3) Click "New."
4) Type ".flv" as the associated extension and "video/x-flv" as the content type.
5) Click "OK"
6) Click "OK"

SQL Express 2008 Install Consistency Rule Failed

Oh happy days - SQL Express 2008 has failed to install with the following error:

"Rule 'Consistency validation for SQL Server registry keys' failed". The SQL Server registry keys from a prior installation cannot be modified. To continue, see SQL Server Setup documentation about how to fix registry keys.

The most likely cause is registry permissions, DO NOT try some users advice of uninstalling all copies of SQL Server, at least not until you have checked the registry permissions.

You will find the installation log in Program Files\Microsoft SQL Server\100\Setup Bootstrap\LOG folder. Open the log and check for any errors in the steps relating to registry key checks/updates. If the errors relate to security or access permissions this is your problem. Open registry editor, locate the key indicated in the install log, right-click and select Permissions, change the permissions at the very least local administrators have full access. After doing this for each affected key try…

IE Cross Browser Compatibility Testing

Microsoft really have got into the spirit of free software lately. If you aren't already using Expression Studio 3 then Microsoft have provided a free version of their SuperPreview tool that allows quick comparisons of site designs between different browser versions.

More details from Mike Ormond:
http://blogs.msdn.com/mikeormond/archive/2009/09/11/simplifying-cross-browser-compatibility-testing.aspx

MSDN FREE Firestarter Events

MSDN are hosting a couple of free events in the next few weeks to enhance developers skills. The events are in the US (OK so not very practical to attend in person) but will also be web cast so you can dip in and out whenever you wish.All times below are PST.Silverlight – Thursday 17/09/20098:45 am - 9:00 am
Event Kick Off
Mithun Dhar 9:00 am - 10:00 am
Keynote
Scott Guthrie 10:00 am - 11:00 am
Key Silverlight Scenarios
Tim Heuer 11:00 am - 11:15 am
Break11:15 am - 12:15 pm
Expression 3 Overview
(Includes Behaviors)
Adam Kinney 12:15 pm - 1:00 pm
Lunch Break1:00 pm - 1:30 pm
Sketch Flow
Janete Perez 1:30 pm - 2:30 pm
Toolkit & Controls
Justin Angel/
Shawn Oster 2:30 pm - 3:30 pm
RIA Services
Brad Abrams 3:30 pm - 3:45 pm
Break3:45 pm - 4:30 pm
Building Silverlight UIs with XAML Power toys
Karl Shifflett 4:30 pm - 5:00 pm
Q&A Panel
All Speakers ASP.NET MVC – Saturday 03/10/20098:30 am - 9:00 am
Ch…

String.PadLeft() Total Length Clarification

Very quick note on String.PadLeft() to clear up some confusion. The specified total length is actually the minimum total length for the string.

E.g.

"5".PadLeft(2, Convert.ToChar("0"))
Output = 05

"55".PadLeft(2, Convert.ToChar("0"))
Output = 55

"555".PadLeft(2, Convert.ToChar("0"))
Output = 555

Microsoft documentation: http://msdn.microsoft.com/en-us/library/system.string.padleft.aspx

Windows Azure Pricing

This just dropped in. Courtesy ofhttp://geekswithblogs.net/iupdateable/archive/2009/07/15/azure-pricing-and-sla-announcements-plus-details-on-the-two.aspxFull pricing details: http://www.microsoft.com/azure/pricing.mspxPrices:
Windows Azure: * Compute = $0.12 / hour
* Storage = $0.15 / GB stored / month
* Storage Transactions = $0.01 / 10K
* Bandwidth = $0.10 in / $0.15 out / GBSQL Azure: * Web Edition– Up to 1 GB relational database = $9.99
* Business Edition– Up to 10 GB relational database = $99.99
* Bandwidth = $0.10 in / $0.15 out / GB.Net Services: * Messages = $0.15/100K message operations , including Service Bus messages and Access Control tokens
* Bandwidth = $0.10 in / $0.15 out / GB

Shipping an application with SQL Server Express 2008 - Rights

Shipping an application with SQL Server Express 2008? Don't forget to register for free redistribution rights: http://www.microsoft.com/sqlserver/2008/en/us/express/redistregister.aspx

Quoted from Microsoft:

This redistribution license agreement grants you the right to redistribute with your software application the following components:

*SQL Server 2008 Express
*SQL Server 2008 Express with Advanced Services
*SQL Server 2008 Express with Tools

Helpful download links for SQL Server Express 2008 Prerequisites

Enable Samesite for the .NET Framework 3.5 SP1 bootstrapper package

Lifted from the full VS 2008 SP1 http://download.microsoft.com/download/A/2/8/A2807F78-C861-4B66-9B31-9205C3F22252/VS2008SP1Readme.htm#General%20Issues as I have seen quite a few people run into this.

If the .NET Framework 3.5 SP1 bootstrapper package is selected in the Prerequisite dialog box for a Setup project or in ClickOnce publishing, and also the "Download prerequisites from the same location as my application" option is selected, the following build error is shown:

The install location for prerequisites has not been set to 'component vendor's web site' and the file 'dotNetFx35setup.exe' in item 'Microsoft.Net.Framework.3.5.SP1' cannot be located on disk.

To resolve this issue:

Update the Package Data
Open the [Program Files]\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder or %ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems Edit the Product.xml file in Notepa…

Visual Studio 2005 Bootstrapper - Using Packages from VS 2008

Visual Studio 2005 bootstrapper packages folder: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages

The later, VS 2008, packages can be used in VS 2005 by installing the latest Windows SDK then copying the packages from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages into the folder listed above for Visual Studio 2005. Launch a new setup project in VS 2005 and the packages will be available as prerequisites.

WSE 2 configuration error

If you have received an error similar to the one below, just make sure you have installed WSE 2 on the target server!!!Download WSE 2 from here: http://www.microsoft.com/Downloads/details.aspx?familyid=1BA1F631-C3E7-420A-BC1E-EF18BAB66122&displaylang=enConfiguration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.

Parser Error Message: The 'type' attribute must be set to a valid type name.

Source Error:

Line 79:
Line 80:
Line 81:
Line 82:
Line 83:

VS 2005 CS0030: Cannot convert type Login

If you are getting an error like the one below then ASP.NET then checkout http://www.groupsrv.com/dotnet/about147910.html

If the site has been published and has been marked as updateable and you have a class in the application named login then it can result in the error below, the simplest resolution is to rename your class.

Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Event Type: Warning Event Source: ASP.NET 2.0.50727.0 Event Category: Web Event Event ID: 1310 Date: 11/7/2005 Time: 10:43:16 AM User: N/A Computer: DEVPC01 Description: Event code: 3007 Event message: A compilation error has occurred. Event time: 11/7/2005 10:43:16 AM Event time (UTC): 11/7/2005 4:43:16 PM Event ID: 6c82372492fa42dbbbd4a0f5b794ed8d Event sequence: 40 Event occurrence: 7 Event detail code: 0

Exception information: Exception type: HttpCompileException Exception message: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\deleted\3ee2c232\438386…

Google Maps - IE 8 - Click Position

The position (point) returned by the click event on Google Maps in Internet Explorer 8 is incorrect - at least in some configurations.The recommendations I have found so far are to remove the DOCTYPE tag or to add in the compatibility meta tag for IE, to be honest I'm not sure which is worse!!Discussed here:
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/9946215e23a3bdf2Microsoft explanation of the new compatibility meta tag:
http://msdn.microsoft.com/en-gb/library/cc817574.aspx

Preventing XSS in ColdFusion

How to prevent cross site scripting in ColdFusion. Useful page from The Dev Shack:
http://www.thedevshack.com/preventing-xss-cross-site-scripting-attacks-in-coldfusion/

Essentially:
Enable Global Script Protection in your application. You can accomplish this by using the scriptProtect attribute in your application.cfc. You can also globally enable script protection at the server level via the ColdFusion Administrator. Under settings check Enable Global Script Protection.Use HTMLEditFormat around ANY variables that contain user submitted input.Search and replace any maliciuous data. Replace script tags, etc… with nothing.Validate user submitted input on the server side. Check data types and lengths.

Cross site scripting (XSS) links to information

Useful resources explaining Cross Site Scripting (XSS) and how to code/guard against it.

CERT® Advisory CA-2000-02 Malicious HTML Tags Embedded in Client Web Requests
http://www.cert.org/advisories/CA-2000-02.html

Cross-site Scripting (XSS)
http://www.owasp.org/index.php/Cross-site_scripting

Data Validation
http://www.owasp.org/index.php/Data_Validation

Reviewing Code for Cross-site scripting
http://www.owasp.org/index.php/Review_Code_for_Cross-site_scripting

XSS (Cross Site Scripting) Prevention Cheat Sheet
http://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet

OWASP Enterprise Security API
"OWASP Enterprise Security API Toolkits help software developers guard against security-related design and implementation flaws. Just as web applications and web services can be Public Key Infrastructure (PKI) enabled (PK-enabled) to perform for example certificate-based authentication, applications and services can be OWASP ESAPI-enabled (ES-enabled) to enable applications …

PCI Compliance - ColdFusion Debug Information

It should be blocked anyway but it is a common problem when undergoing PCI Compliance that ColdFusion debug information may be displayed by appending mode=debug to any CF URL. To prevent this limit the IPs that can access the debug information, preferably limit this to 127.0.0.1:

Open CF administrator
Select "Debugging Ips"
Add 127.0.0.1
Remove all other IPs

Too many backup devices specified for backup or restore; only 64 are allowed

When you try to restore a database backup, the restore operation may fail. You may receive an error message that is similar to the following:

Server: Msg 3205, Level 16, State 2, Line 1
Too many backup devices specified for backup or restore; only 64 are allowed.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

The message doesn't necessarily mean what it says. The following are possible causes:

You want to restore a database backup that spans across multiple backup devices, and you have not specified more than 64 backup devices.
You created the database backup on a computer that is running SQL Server 2000 Service Pack 3 (SP3) (Build 2000.80.869.0) or a later build of SQL Server 2000 SP3.
You try to restore the database backup on a computer that is running a build of SQL Server 2000 SP3 that is earlier than 2000.80.869.0.
You are trying to restore a database created in SQL Server 2005 or SQL Server 2008 to an instance of SQL Server 2000 - not mentione…

Change IDENTITY SEED using T-SQL

DBCC CHECKIDENT ({{TABLENAME}}, RESEED, {{NEW SEED}})Be VERY careful to check the results of this command, it is possible to set the seed lower than the current maximum value of the identity column. If this is not checked and more records are inserted then you can run into serious trouble!

Converting Excel date format into System.DateTime

public static DateTime ConvertToDateTime(double excelDate)
{
if (excelDate < 1)
{
throw new ArgumentException("Excel dates cannot be smaller than 0.");
}
DateTime dateOfReference = new DateTime(1900, 1, 1);
if (excelDate > 60d)
{
excelDate = excelDate - 2;
}
else
{
excelDate = excelDate - 1;
}
return dateOfReference.AddDays(excelDate);
}

http://www.clear-lines.com/blog/post/Converting-Excel-date-format-to-SystemDateTime.aspx

SAGE Line 50 2009 Install Problems With 'manager' login

A few of our clients have experienced problems with fresh installs of SAGE Line 50 where they have completed a clean install and they cannot login to the application using the default user "manager" and a blank password - this applies to both the new company data and the demo data. In each case the problem has been caused by either denied access on the MS MachineKeys folder and/or a corrupt company setup file.

First try the following:
1. Browse to C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA
2. Right-click the MachineKeys folder and select Properties.
3. Select the Security tab
4. Ensure your user has at least Modify permissions on the folder.
5. Click Advanced
6. Tick the box for "Replace permission entries on all child objects…"
7. Select the Owner tab.
8. Ensure the owner is either your user or a group your user belongs to.
9. Click OK
10. Try to login to SAGE.

If the above fails:
1. Browse to C:\Documents and Settings\All Users\Application Dat…

How to loop through all files in a folder or directory tree

The code is fairly self explanatory:

/// sourceDir = directory to scan, scanLvl = current scan level, maxLvl = how deep to scan, searchPattern files to match

public staticvoid ProcessFiles(string sourceDir, int scanLvl, int maxLvl, string searchPattern)
{
if (scanLvl<=maxLvl)
{
string [] fileEntries = Directory.GetFiles(sourceDir, searchPattern);
foreach(string fileName in fileEntries)
{
// do something with file
}

// Recurse into subdirectories
string [] subdirEntries = Directory.GetDirectories(sourceDir);
foreach(string subdir in subdirEntries)
if ((File.GetAttributes(subdir) &
FileAttributes.ReparsePoint) !=
FileAttributes.ReparsePoint)
ProcessDir(subdir, scanLvl+1, maxLvl, searchPattern);
}
}
Thanks to Ohad for the starting point for this one.

Internet Explorer 8 - Oh Dear!

Well, having had the final release of IE 8 installed for approximately 20 hours it has so far hung countless times and crashed completely on 5 occasions.

I am a fairly intensive user constantly opening and closing tabs but I'm not viewing particularly intensive sites - how can the browser have been in development so long and still be this bad!!

Google StreetView for UK goes live

Google has launched the UK version of it's Street View service, the new service covers:
AberdeenBelfastBirminghamBradfordBristolCambridgeCardiffCoventryDerbyDundeeEdinburghGlasgowLeedsLiverpoolLondonOxfordManchesterNewcastleNorwichNottinghamScunthorpeSheffieldSouthamptonSwanseaYorkThe major issue for street view is privacy. Google has had agreement from the information commissioner because they have automatically blurred the faces of individuals and vehicle numer plates in all images, the only problem is that their software isn't perfect... you'd better hope this isn't your car.

Dynamically loading CSS in Safari and Google Chrome

Having developed a new AJAX enabled content viewer for a client's website I found that it would not load correctly in Google Chrome or Safari. The content being loaded into the viewer DIV included the CSS styles for the content and the HTML content itself, by loading the CSS into the container DIV it was being loaded outside of the document header - this is not valid in Safari as all style definitions must be placed in the head section - as a result the content loads without any CSS being applied.

To fix this the AJAX request has been split into two requests, the first loads the HTML into the DIV, the second loads the CSS and writes it into a style tag in the head section - this works in all browsers. Unfortunately this isn't as easy as it sounds due to various browser quirks when creating style elements, populating the element and adding it to the head section.

Essentially the following code will ensure the style element is created correctly:

function addCss(cssCode)
{
var styleE…

Installing SQL Server Express 2005 on Windows 2008 SBS

Due to what frankly seems to be a complete botch from Microsoft SQL Server Express 2005 can be a pain to get installed on Windows Server 2008 SBS.

See:
http://technet.microsoft.com/en-us/library/cc794697.aspx

Especially:

Installing SQL Server 2005
If you plan to install SQL Server 2005 on the original server running Windows SBS 2008, do the following before you run the installation.

Click Start, click All Programs, click Accessories, and then click Run.
Type regedit, and then click OK.
At the User Account Control prompt, click OK.
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90.
Double-click OriginalMachineName, and then change the OriginalMachineName value name to the current server name.
Click OK.

Developer Developer Developer South West Taunton 23rd May 2009

From the DDD South West site: DDD South West is a free one day technical event for developers. It is a day of learning, discussing, contributing and being part of the community in the South West. Our goal is to provide free technical education, the opportunity to mix with peers and to make and develop relationships in the .NET industry.

Free registration started on 2nd March 2009, get over to the DDD site now to register.

Ad hoc access to OLE DB provider has been denied

Using post SP2 SQL 7 (+ 2000 etc) attempting to access an OLEDB data source using OPENROWSET can produce the slightly spurious error:

Ad hoc access to OLE DB provider 'MSDASQL' has been denied. You must access this provider through a linked server.

In usual Microsoft style the message doesn't really mean what it says. From SQL 7 SP2 onwards MS by default blocked ad hoc query access with OLEDB. As the message suggests you could setup a linked server but that can be a real pain. Alternatively if you need ad hoc access server wide you could turn on ad hoc access for the SQL server you are using, explained in MS speak here:

http://support.microsoft.com/default.aspx?kbid=266008

Ah, but it's not that simple. A little more witchcraft is required. The following registry settings can be used to enable ad hoc access:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers] "DisallowAdhocAccess"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Pr…

Command line shut down or restart

Quite frequently all PCs in our office have to be restarted for various updates, configuration changes etc. We also have a policy of all PCs being turned off overnight and have become a little draconian in enforcing this - the electricity bills are huge otherwise!

A local or remote shut down or restart can be triggered using the command line.

shutdown [-i -l -s -r -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u] [p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the …

Disable SSLv2 in IIS 6 for PCI Compliance

Anyone working on PCI Compliance will know the restrictions placed on IIS. The recommendations are only common sense but remarkably few companies have implemented them.

SSLv2
SSLv2 has always been full of holes and there is now very little need for it to be enabled on any server. Almost no clients require it and if it is enabled it is potentially a serious security problem.

Open Registry Editor.
Select HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server
On the Edit menu select New then DWORD Value
Name the new value Enabled
Ensure the value is set to 0
Restart the server


Full details on disabling SSLv2 can be found in the following MS knowledge base article:
http://support.microsoft.com/kb/187498

Cryptographic Algorithms
If the scan for PCI compliance has picked up SSLv2 then it will almost certainly have warned about a number of weak algorithms (http://support.microsoft.com/kb/245030)

The following list need to be disabled to ensure the only Cip…

CFDOCUMENT Font Issues - Type 1

This has been reported many times but there are a number of issues with CFDOCUMENT and embedding fonts in PDFs - in particular in MX7. One client required a PDF to use the Dax font and had initially provided Type 1 fonts, these of courses didn't work as ColdFusion didn't recognise them. TrueType TTF fonts were then provided but still didn't work despite the fonts being installed in the system fonts folder and being correctly referenced by the font family name in the page CSS.

The core issue is that CFDOCUMENT will attempt to use the first version of a font with a matching font-family name - regardless of it's type. Our system had Type 1 and TrueType versions of Dax installed but CFDOCUMENT always tried to use the Type 1 version. The only way to resolve the issue was to completely remove the Type 1 version, the output now works perfectly!

Add a range of ports to Windows Firewall from the command line

To add a range of ports to Windows Firewall from the Command Line:

Click Start, click Run, type cmd, and then click OK.
Type in the following where the range is specified in brackets and the name you choose for the firewall entry is in double quotes.
FOR /L %I IN (5001,1,5201) DO netsh firewall add portopening TCP %I "Passive FTP"%I
Each port in the range will be added with an "OK" confirmation.

Enabling Passive FTP on Windows 2003 with Windows Firewall

After much searching I have finally (!) located the best way of enabling passive FTP through Windows Firewall.

On Windows 2003 Server with IIS6
To Enable Direct Metabase Edit

Open the IIS Microsoft Management Console (MMC).
Right-click on the Local Computer node.
Select Properties.
Make sure the Enable Direct Metabase Edit checkbox is checked.

Configure PassivePortRange via ADSUTIL script

Click Start, click Run, type cmd, and then click OK.
Type cd Inetpub\AdminScripts and then press ENTER.
Type the following command where the range is specified in "..". cscript.exe adsutil.vbs set /MSFTPSVC/PassivePortRange "5001-5201"
Restart the FTP Publishing Service.
You'll see the following output, when you configure via ADSUTIL script:
Microsoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
PassivePortRange : (STRING) "5001-5201"


Add each port to the Windows Firewall

Click Start, click Control Panel, open Windows Firewa…

Recover from corrupt SQL LDF transaction log file

Another favourite this month. A fault on one of our client's servers caused it to restart once every 10 minutes for 2 hours - the result was a corrupt LDF transaction log file for the main application database.

It is surprisingly simple to recover from this situation:

1. Stop the SQL Server service
2. Copy the affected database (both LDF and MDF files) out of the main data folder.
3. Restart the SQL Server service
4. Create a new database of the same name and location as the database affected in step 2 - it is critical the filenames and paths are identical.
5. Stop the SQL Server service.
6. Copy the original MDF file (copied in step 2) in to replace the new MDF file created in step 4
7. Start the SQL Server service - the database will show as being suspect.
8. Now you need to recover the database, working from Query Analyser or SQL Management Studio:

Use master
go

sp_configure 'allow updates', 1
reconfigure with override
go

select status from sysdatabases where name = '{{DBName}}…

IIS6 - which W3WP.EXE belongs to which application pool

Our servers run with a number of application pools to separate load between several intensive websites/processes. When everything is running fine management is easy but if an application pool begins to use excessive resource it is necessary to identify which W3WP.EXE process is using the resource and therefore which app pool is causing the problem.

Microsoft have provided a script file (.vbs) to list all W3WP.exe processess, the PID and the application pool. Simply open a command prompt (Start > Run, enter "cmd", click OK), type iisapp and hit return. Below is an example of the output:

W3WP.exe PID: 1468 AppPoolId: AppPoolForSite1.com
W3WP.exe PID: 3056 AppPoolId: AppPoolForSite2.com
W3WP.exe PID: 1316 AppPoolId: AppPoolForSite3.com

Thank you ASP Alliance for this one:
http://aspalliance.com/576

Shrink SQL Server Log File LDF

Having recently had a very intensive database with limited data generating a huge transaction log file (>4Gb for a 150Mb database) it was necessary to carry out a temporary truncate and then schedule once per day, the following prodecure is very effective:

USE {{DatabaseName}}
GO

DBCC SHRINKFILE({{FileName}}, 1)
GO

BACKUP LOG WITH TRUNCATE_ONLY
GO

DBCC SHRINKFILE({{FileName}}, 1)
GO