Create default statement)

Source: Internet
Author: User

Microsoft's explanation:

Create an object called the default value. When bound to a column or alias data type, if no value is explicitly provided during insertion, a value is specified by default to insert it into the column bound to the object (or, if the data type is an alias, all columns are inserted ).

This function will be deleted in later versions of Microsoft SQL Server. Avoid using this function in new development work, and start to modify the application that is currently using this function.

 

 

Syntax

CREATE DEFAULT [ schema_name . ] default_nameAS constant_expression [ ; ]
Parameters

Schema_name

The name of the default schema.

Default_name

The default value. The default name must comply with the identifier rules. You can choose whether to specify the default owner name.

Constant_expression

It only contains regular value expressions (it cannot contain the names of any column or other database objects ). Except for expressions that contain alias data types, you can use any constant, built-in function, or mathematical expression. You cannot use user-defined functions. Character and date constants must be placed in single quotes ('); No quotation marks are required for currencies, integers, and floating-point constants. Binary data must start with 0x, and currency data must begin with the dollar sign ($. The default value must be compatible with the column data type.

Example: create default time

 

----- Create Default defadefadate AS GetDate () ----- bind the Default value to the specified column EXEC sp_binDefault @ DefName = MyDate, @ ObjName = 'product. Made 'in the table to bind the Default value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.