Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2003, 11:13 AM
Authorized User
 
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Default Value = Todays Date

I have a table with three fields. The second field is a date field.
How do I set a default value of todays date in the table design grid?

CEJ
__________________
CEJ
 
Old July 28th, 2003, 01:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Simply select the column in design view and enter an expression for the current date in the 'Default Value' entry on the properties page in the 'Columns' portion of the lower screen.

Thus, a default value of getdate() will set the value of the column top right now if no value is supplied when a row is inserted.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old July 28th, 2003, 10:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

CREATE TABLE dbo.TABLE1
(
  field1 ...
  ,field2 smalldatetime defualt getdate()
  ,field3 ...
)

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Date Value mean34dean Access 2 September 17th, 2008 04:20 PM
Todays date and date of 3 days later Singh591 Visual Basic 2005 Basics 1 December 21st, 2006 06:06 PM
DATE / TIMESTAMP default values WarHead MySQL 2 April 20th, 2006 10:18 AM
Change default date parameter format JeffHickman Reporting Services 0 February 14th, 2006 06:52 AM
Selecting Data Based on Todays Date worshiploud Classic ASP Basics 2 June 29th, 2003 07:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.