views:

28

answers:

3

Can anyone explain how this constraint functions and how its affects insertion of records into this table? Running win sql 2k5. Having issue with trying to insert data.

  ALTER TABLE [dbo].[ws_shiptable] ADD  CONSTRAINT [DF_ws_shiptable_ps_processed]  DEFAULT (0) FOR [ps_processed]
+1  A: 

It adds a default value of 0 for column ps_processed. If you do an insert and you don't specify a value for ps_processed, it'll default to 0. What is the issue you are having? Do you get error messages you can post? A default value shouldn't give you trouble, but make sure ps_processed has the right data type. I suspect it'll be a bit field?

Rob
A: 

If no value is provided for the column ps_processed then SQL Server will set the value to zero

Barry
A: 

As the other 2 had mentioned its setting a default value of 0 for that field, which will be used unless data is passed to that field,

This value will also show up in the table design for ws_shiptable, in the Default Value or Binding Property.

kevchadders