dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2008
    Posts
    102

    Cool Set column default value in SQL Server

    How to assign default value for a particular column in database?

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    What kind of database?

  3. #3
    Join Date
    Feb 2008
    Posts
    102
    sql database

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    SQL Server 2000? SQL Server 2005?

    What kind of value do you want to assign to what column?

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Set the default value for the column in SQL Server Enterprise Manager (for SQL 2000) or Management Studio (for 2005 or newer). See http://searchsqlserver.techtarget.co...164428,00.html for more information.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  6. #6
    Join Date
    Feb 2008
    Posts
    21
    Default value can be assigned jus by adding a constraint like this:

    create table CustReport
    (
    customer_id int,
    report_id int,
    rundate datetime not null
    constraint df_CustReport_rundate default getdate()
    )
    go

  7. #7
    Join Date
    Aug 2009
    Posts
    1

    Set default value to column

    Setting default value to columns 'Address' and 'City' in this example-

    CREATE TABLE Members
    (FName char(50),
    LName char(50),
    Address char(150) default 'Common',
    City char(50) default 'Delhi',
    Country char(25),
    BDate datetime)

Similar Threads

  1. Create XML file from a string in SQL server 2000
    By shan_2007 in forum Database
    Replies: 0
    Last Post: 12-11-2007, 06:34 AM
  2. SQL server vs Access
    By Samantha in forum Database
    Replies: 6
    Last Post: 01-25-2002, 02:15 PM
  3. Replies: 1
    Last Post: 01-11-2002, 07:04 PM
  4. Can Sql Server do this?
    By DavidR in forum Database
    Replies: 5
    Last Post: 02-14-2001, 11:46 PM
  5. Re: ODBC error
    By Devaraj in forum Enterprise
    Replies: 0
    Last Post: 05-11-2000, 12:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center






×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.