On Northwind database in SQL Server 2000, I try to setup default value at
table design windows for "OrderDate" using GETDATE(), but it does not work.
How do I use setup GETDATE default value for date type? Thanks
KaiOn Sun, 09 May 2004 03:39:07 GMT, kai wrote:
>Hi, All
> On Northwind database in SQL Server 2000, I try to setup default value at
>table design windows for "OrderDate" using GETDATE(), but it does not work.
>How do I use setup GETDATE default value for date type? Thanks
>Kai
Hi Kai,
ALTER TABLE MyTable
ADD DEFAULT GETDATE() FOR MyColumn
go
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||What do you mean exactly by 'it does not work'? Note that the default value
is used only when the column is omitted from the INSERT column list.
To add to Hugo's response, it's a good idea to name constraints explicitly
so that subsequent schema maintenance is easier:
ALTER TABLE MyTable
ADD CONSTRAINT DF_MyTable_MyColumn
DEFAULT GETDATE() FOR MyColumn
--
Hope this helps.
Dan Guzman
SQL Server MVP
"kai" <kailiang@.earthlink.net> wrote in message
news:vJhnc.3578$KE6.2982@.newsread3.news.atl.earthl ink.net...
> Hi, All
> On Northwind database in SQL Server 2000, I try to setup default value
at
> table design windows for "OrderDate" using GETDATE(), but it does not
work.
> How do I use setup GETDATE default value for date type? Thanks
> Kaisql