Comments on: SQL SERVER – Create Default Constraint Over Table Columnhttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/
SQL, SQL Server, MySQL, Big Data and NoSQLTue, 31 Mar 2015 08:37:37 +0000hourly1http://wordpress.com/By: anoopnirmalahttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-962062
Mon, 31 Mar 2014 14:07:43 +0000http://sqlauthority.wordpress.com/?p=622#comment-962062Hi ,
I am trying to create a constraint where I am trying to update a column to Y or N depending on two other fields in the table
Ex : Create_Date and Expiry_date for a product is defined and another column named Active_Flag wherein if Create_Date is “2014-03-10 00:00:00.0000000″ and Expiry_Date is “2014-03-25 12:00:00.00000000″ and current_date “2014-03-19 00:00:00.0000000″ then automatically Active_Flag should update “Y”
Ex2 : Create_Date and Expiry_date for a product is defined and another column named Active_Flag wherein if Create_Date is “2014-03-10 00:00:00.0000000″ and Expiry_Date is “2014-03-25 12:00:00.00000000″ and current_date “2014-03-27 00:00:00.0000000″ then automatically Active_Flag should update “N”

]]>By: Joe Solishttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-559833
Thu, 15 Aug 2013 20:54:08 +0000http://sqlauthority.wordpress.com/?p=622#comment-559833I need to set a column to NULL if an amount column in the same table is = 0, or set the column to NOT NULL if the amount column is > 0.

]]>By: namitahttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-558170
Wed, 14 Aug 2013 21:48:19 +0000http://sqlauthority.wordpress.com/?p=622#comment-558170i have tried same syntax for adding default contraint
ALTER TABLE tblperosontable
ADD CONSTRAINT DF_tblpersontable_genderid
DEFAULT 3 for genderid
but i get following error :
“cannot find the object “tblperosontable” because it does not exist or you do not have permissions.”
i have logged as SA user ..
and can you please tell me how to add default constraint graphically in sql server management studio.
Thanks for your help
namita

]]>By: Matt Fairfieldhttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-405828
Wed, 09 Jan 2013 20:46:09 +0000http://sqlauthority.wordpress.com/?p=622#comment-405828I have done this but now upon insert of a new record the value is not defaulting to 0 (zero) why?

i read this article and this is correct that we can add the default constraint by this , but on msdn and technet i found different syntax which is not working for me , giving me syntax error
i am also posting the link where i found these information

]]>By: LeyaLihttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-92113
Mon, 11 Oct 2010 12:20:05 +0000http://sqlauthority.wordpress.com/?p=622#comment-92113I have a Domain Data table that is being added at the same time a FK is being created refrencing the new table. The problem is the data in the new table is not instered until the post script so the creation of the FK fails. How would you handle this? I tried createing the table in the pre script but then i fail because the table already exists when data dude tries to add it.

]]>By: Billigflug Phukethttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-39386
Fri, 20 Jun 2008 11:18:33 +0000http://sqlauthority.wordpress.com/?p=622#comment-39386Thank you very much. I´ve just begun to develop things and this script was very useful for me.

]]>By: Karinahttp://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/#comment-39319
Wed, 18 Jun 2008 11:21:07 +0000http://sqlauthority.wordpress.com/?p=622#comment-39319i have a problem like this:
i have a column that can get the values: Y or N
how do i wirte a script that allows only one row at every given moment to be Y and all others N.
i want this as a constraint or something like this.
thanks in advance,
Karina