How to set a default value created by the user when creating a table (SQL Server)?

0

I created a default value for my database:

CREATE DEFAULT [dbo].[zero] as 0

However, I can not create a table using this default value. How do I set this value at the time of creating a table? For example:

CREATE TABLE TESTE ( num int DEFAULT zero)
    
asked by anonymous 02.12.2014 / 12:52

1 answer

1

You can set the default value of the "num" field when creating the TEST table like this:

CREATE TABLE TESTE
(
    num int DEFAULT (0)
)

This "CREATE DEFAULT" feature will be removed in a future release of Microsoft SQL Server as msdn , so it's good to avoid it.

    
02.12.2014 / 13:26