how to initialize datafield to zero instead of NULL

  • hello im facing this rather easy problem. i want to use an integer datafield to calculate balance.i want the first data inside the field to be zero(0) so that i can use it to increment/decrement the default balance value.but the first data is NULL so it isnt participating in calculations.i dont know if you've got me or not.if you've got me then please try to help me or if you haven't then ask me specifically

  • Create a DEFAULT for your column. You can do it via T-SQL or Table Design in SSMS

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • If you mean a column in a table, you can add a default value to one, like this:

    alter table dbo.MyTable

    add default(0) for MyColumn ;

    You'll need to use real table and column names, of course.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 3 posts - 1 through 2 (of 2 total)

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