Re: simple ALTER TABLE question
From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 01/24/05
- Next message: Allan Mitchell: "Re: Question regarding SP"
- Previous message: Aaron Weiker: "Re: Question regarding SP"
- In reply to: Michael C: "Re: simple ALTER TABLE question"
- Next in thread: Michael C: "Re: simple ALTER TABLE question"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 24 Jan 2005 16:55:39 -0500
Right, and the NOT NULL constraint added at column creation time makes sure
that existing insert statements that do *not* include this column will
continue to work (assuming there is a column list, of course) and will not
leave this column with NULL...
-- http://www.aspfaq.com/ (Reverse address to reply.) "Michael C" <me@mine.com> wrote in message news:OnB5j8lAFHA.1300@TK2MSFTNGP14.phx.gbl... > Scratch that - the NOT NULL clause he specified takes care of that for you. > > Thanks, > Michael C#, MCDBA > > "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message > news:exfdA2lAFHA.1452@TK2MSFTNGP11.phx.gbl... > > > ALTER TABLE ADD COLUMN MyNewField BIT SET DEFAULT 0 > > > > > > but that doesn't work. > > > > Where did you get the SET keyword? Also, for some reason, COLUMN is not > > allowed here (but only when ADDing). Finally, you should specify whether > > the column allows NULLs or not. If you want existing rows to have 0, and > or > > existing insert statements to populate the default value, Try: > > > > ALTER TABLE tablename ADD MyNewField BIT NOT NULL DEFAULT 0 > > > > A > > > > > >
- Next message: Allan Mitchell: "Re: Question regarding SP"
- Previous message: Aaron Weiker: "Re: Question regarding SP"
- In reply to: Michael C: "Re: simple ALTER TABLE question"
- Next in thread: Michael C: "Re: simple ALTER TABLE question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|