Monthly Archives: February 2010

Add Column with a check on acceptable range of values

Here is the code to add a new column to an existing table with a check on range. The following column only allows values of 0,1 or 2. IF NOT EXISTS (SELECT c.name FROM dbo.sysobjects s INNER JOIN dbo.syscolumns c … Continue reading

Posted in Development | Tagged | Leave a comment

Dropping unnamed default constraints

Ron Talmage article on Default constraints explains why we should always name our default constraints. In case you created a table with unnamed default constraint then SQL server automatically assigns one for you, scripting to drop that column would be … Continue reading

Posted in Development | Tagged | Leave a comment

WCF service Hosted on IIS in Windows 2003 needs write access to windows temp directory

I migrated my WCF services to Prod windows 2003 box and started getting the following error. Error: Cannot import wsdl:portTypeDetail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporterError: Schema with target namespace ‘http://www.odh.ohio.gov/ELR2/contract’ could not be found … Continue reading

Posted in Development | Tagged | Leave a comment

SQL 2005 drop unique constraint

I just realized that we can not use drop constraint to drop a unique constraint on a table. Since unique constraint is implemented as index we need to drop the index. IF EXISTS (SELECT name FROM sys.indexes WHERE name = … Continue reading

Posted in Development | Tagged | Leave a comment