How to set up a default value for a data field in SQL Server 2005

  • How do I set up a data field so that it will have a specific default value?

    For example, a default value of '0'.

    Thanks in advance, Bill

     

     

  • Hello Bill,

    You can set the default value to the required like this

    Alter Table <your table name>

    alter column <column name> set default <your value>

    Hope this helps.

    Thanks

     


    Lucky

  • I like your information you shared with me Luck but it looks like these commands are to be run from query analyzer

    Do you know if there is a way to do this through the GUI of SQL server 2005, or GUI or SQL Server 2005 analyzer studio?

     

     

  • William

    In management studio, you can set default values in the column property section which appear on the bottom half of the work screen.  It does not appear until you are enter or click on a column name.  Hope this helps

     

    Marvin

    Marvin Dillard
    Senior Consultant
    Claraview Inc

  • William

    To answer your other question about query analyzer, in Management Studio, select the database you wish to query against. Also, ensure that you have the Standard Toolbar selected (View\Toolbars\Standard) and you should see a button for New Query. Click on that button to run a query against the database selected.

    This tool replaces SQL Query Analyzer that was in SQL2000.

    Chuck

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply