How to Change a Column to Allow NULL in SQL Server

If you have a column in a SQL Server table that does not allow NULL values and you need to change it to allow NULLs, here is how you do it.

Let's say, you created a table like this:

CREATE TABLE Employees (
  EmployeeID int IDENTITY(1,1) PRIMARY KEY,
  FirstName NVARCHAR(25) NOT NULL,
  LastName NVARCHAR(25) NOT NULL
);

Then you hire Madonna and realize you need to make LastName nullable. Here's how you change it.

ALTER TABLE Employees ALTER COLUMN LastName NVARCHAR(25) NULL;
Author: Nat Dunn

Nat Dunn is the founder of Webucator (www.webucator.com), a company that has provided training for tens of thousands of students from thousands of organizations. Nat started the company in 2003 to combine his passion for technical training with his business expertise, and to help companies benefit from both. His previous experience was in sales, business and technical training, and management. Nat has an MBA from Harvard Business School and a BA in International Relations from Pomona College.

Follow Nat on Twitter at @natdunn and Webucator at @webucator.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.