title: DEFAULT CONSTRAINT full form
body: <p>For each table constraint, I see that there are <em>shorthand</em> form, <em>semi-shorthand</em> form and <em>full</em> form (Pardon me for the naming. Suggestions of how to correctly call them are welcome)</p>
  
  <p>For example </p>
  
  <p>Shorthand form: let constraint name be defined by SQL Server, column to be affected is implied as the column being defined</p>
  
  <pre><code>CREATE TABLE myTable
  (
      id int PRIMARY KEY,
  )
  </code></pre>
  
  <p>Semi-shorthand form: explicit constraint name, implied column</p>
  
  <pre><code>id int CONSTRAINT PK_ID PRIMARY KEY,
  </code></pre>
  
  <p>Full form : both explicit. Allow definition at the end separated from column definition</p>
  
  <pre><code>id int,
  Name varchar(40),
  CONSTRAINT PK_ID PRIMARY KEY(id)
  </code></pre>
  
  <p>From what I see, the full form is seen often in <code>ALTER TABLE</code>, where constraints are defined afterwards.</p>
  
  <p>For <code>DEFAULT</code> constraint </p>
  
  <p>Short-hand form</p>
  
  <pre><code>id int DEFAULT newid()
  </code></pre>
  
  <p>Semi-shorthand form</p>
  
  <pre><code>id int CONSTRAINT DF_ID DEFAULT newid()
  </code></pre>
  
  <p>I see a full-form use in <code>ALTER TABLE</code> as <a href="https://technet.microsoft.com/en-us/library/aa175912(v=sql.80).aspx" rel="nofollow">here</a></p>
  
  <pre><code>ALTER TABLE [dbo].[Customers] WITH NOCHECK ADD 
    CONSTRAINT [DF__Customers__cust___151B244E] 
    DEFAULT ('new customer') FOR [cust_name],
    CONSTRAINT [def_last_updated_by] DEFAULT 
    (suser_sname()) FOR [last_updated_by],
    PRIMARY KEY  CLUSTERED 
    ([cust_id])  ON [PRIMARY] 
  GO
  </code></pre>
  
  <p>However, full-form definition when creating table fails</p>
  
  <pre><code>CREATE TABLE testGUIDs
  (
      ID uniqueidentifier,
      Name varchar(40),
      CONSTRAINT DF_ID DEFAULT newid() FOR [ID]
  )
  GO
  </code></pre>
  
  <p>with an error</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'for'.</p>
  </blockquote>
  
  <p>Can anyone suggest why this error occurs and how to use full-form definition of Default constraint? </p>