From the course: SQL Server 2008 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Creating default values - SQL Server Tutorial
From the course: SQL Server 2008 Essential Training
Creating default values
When you're designing databases, it's a good idea to apply as many rules or constraints to your data as possible. And one of the classic ways to do this is by setting up default values for your columns. The idea of this of course is simple. We have a table such as an OrderItem table made of product IDs and quantities and unit prices. Whereas a lot of this information is very different from row to row, Quantity for example might typically be the number 1. Occasionally it might be 2, but nine times out of ten or nineteen times out of twenty or ninety-nine out of a hundred it will be the number 1. So we will make this the default value for that column, so it doesn't always have to be entered, either by the application or by the user. I'm going to go into my OrderItem table in SQL Server Management Studio and select Design. Applying a default value is very simple. Find the column that you're looking for, in this case Quantity, and then down here in the Column Property section, you'll find…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Planning your database9m 39s
-
(Locked)
Creating a SQL Server database4m 7s
-
(Locked)
Creating tables7m 50s
-
Data types in SQL Server12m 25s
-
(Locked)
Defining keys8m 9s
-
(Locked)
Creating default values4m 39s
-
(Locked)
Creating check constraints2m 25s
-
(Locked)
Creating unique constraints4m 34s
-
Introduction to relationships and foreign keys9m 51s
-
(Locked)
Creating relationships in SQL Server Management Studio8m 14s
-
(Locked)
Database normalization11m 47s
-
(Locked)
Creating computed columns3m 10s
-
-
-
-
-
-
-
-
-
-
-
-