How to change a column collation to the default database collation

If you for some reason needs to change the collation of a column in SQL Server to the default database collation, you can use the following syntax:

ALTER TABLE <table_name> ALTER COLUMN <column_name> <current_data_type> COLLATE database_default

Eg.:

ALTER TABLE myTable ALTER COLUMN myColumn TEXT COLLATE database_default

Posted in SQL Server | Tagged , , | 1 Comment

Unauthorized error when using Integrated Security

Sometimes when I’m setting up a new server and creating a site using only integrated security I am unable to access the site.

Instead of direct access to the site, a dialog pops up asking for user name and password. Even if I enter a valid domain user and the correct password no access is given to the site. After three attempts this message occurs:

HTTP Error 401.1 – Unauthorized: Access is denied due to invalid credentials

IIS is by default using Kerberos for authentication.

This error occurs because the Kerberos authentication for some reason fails.

The easiest way to fix this is to change the default authentication mode for IIS from Kerberos to NTLM.

To change the default authentications mode to NTLM follow these steps:

  1. Open a command window.
  2. Navigate to the Adminscripts folder on the server. This is default found on C:\Inetpub\Adminscripts.
  3. Run the following command:cscript adsutil.vbs set w3svc/NTAuthenticationProviders “NTLM”

  4. Run iisreset

You should now be able to access the site using Integrated Security.

For more information on this issue, check out this KB article: http://support.microsoft.com/kb/871179

Posted in IIS | Tagged , , , | Comments Off on Unauthorized error when using Integrated Security

Debugging gac assemblies

Every now and then somebody says to me:

I just added my assembly to the gac and now I can’t debug my code anymore :(

The fact is that debugging gac assemblies is quite easy when you know how to do it.

The problem with debugging gac assemblies is that you can’t add the pdb file to the gac. What you need to do is to find the actual folder where your assembly is stored and copy your pdb file into this location.

To find this folder you need to run the following command from start->run:

C:\WINDOWS\Assembly\GAC_MSIL

Navigate to your assembly by drilling down in the folders.

Copy your pdb file to the same folder as your dll.

You should now be able to debug your assembly by attaching to the running process.

( If you are not building your assembly as a MSIL assembly you will find it under: C:\WINDOWS\Assembly\GAC or C:\WINDOWS\Assembly\GAC_32 )

Posted in Development | Tagged , , , | Comments Off on Debugging gac assemblies