The Alter Column statement can modify the data type and the Nullable attribute of a column. The syntax is the same for SQL Server 2005 and SQL Server 2008 except 2008 allows the sparse attribute to be changed.
For the example below, we will begin by creating a sample table, then we will modify the columns.
CREATE TABLE dbo.Employee |
EmployeeID INT IDENTITY (1,1) NOT NULL |
,FirstName VARCHAR (50) NULL |
,MiddleName VARCHAR (50) NULL |
,LastName VARCHAR (50) NULL |
,DateHired datetime NOT NULL |
ALTER COLUMN FirstName VARCHAR (100) NOT NULL |
ALTER COLUMN DateHired SMALLDATETIME NULL |
ALTER
COLUMN
MiddleName
VARCHAR
(100) SPARSE
NULL