Partager via


How to: Modify Null Options on Columns

For each column in your table, you can specify whether to allow or disallow null values. A null value, or NULL, is not the same as zero (0) or blank; NULL means that no entry has been made. Its presence usually implies that the value is either unknown or undefined. For example, a null value in a price field of a titles table would not mean that the book has no price, but that the price is unknown or has not been set.

If null values are not allowed, the user entering data in the table must enter a value in the field or the record cannot be accepted in the database.

Note

A new version of Table Designer appears for databases in the SQL Server 2012 format. This topic describes the old version of Table Designer, which you use with databases in earlier formats of SQL Server.

In the new version, you can change a table definition through a graphical interface or directly in a script pane. If you use the graphical interface, the table’s definition is automatically updated in the script pane. To apply the SQL code in the script pane, choose the Update button. For more information about the new version, see How to: Create Database Objects Using Table Designer.

Note

You cannot change this property on a primary key column. Also, identity columns cannot have null values. That is, you cannot create or modify a column so that its Identity setting is Yes and its Nulls Allowed setting is also Yes.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.

To modify the null options on a column

  1. In Server Explorer, right-click the table with null options you want to modify and click Open Table Definition.

    The table opens in Table Designer.

  2. Select the column and in the Column Properties tab either clear or check the Allow nulls check box.

The new value for the Allow nulls check box is assigned to the column in the Table Designer after you click outside the grid cell or use the TAB key to move to another grid cell. It takes effect in the database when you save your changes in the Table Designer.

See Also

Reference

Column Properties

Other Resources

Working with Columns