You are here:
The iPhone and Apple Mac book The iPhone and Apple Mac book

Alter a table that is published under SQL 2005 replication

Having recently implemented Microsoft SQL 2005 replication for a client, we had a few issues with developers trying to alter schema on the database if the table is under replication. The issue is caused because the Microsoft Visual GUI tools for SQL 2005, tries to drop and recreate the table, which is obviously not acceptable if a table is replicated. However there is a way to achieve this and I found this neat code snippet from Paul Ibison - Altering Schema in Microsoft SQL 2005 Server Replication. The statement is as follows:

ALTER TABLE myTable ALTER COLUMN columnName VARCHAR(100) NULL

Not a huge chunk of code, but definitely helpful!