Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Doubth in using Default Constraint... Expand / Collapse
Author
Message
Posted Monday, March 4, 2013 7:14 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, February 27, 2014 6:05 AM
Points: 43, Visits: 162
Hi,

I am creating a new Database. In this i will have a column for to store current Date.

I can specify it as a default Constraint with GetDate() or ask the developers to insert it themselves.

My doubt is which will give the best performance since the database will hold millions of records.

Thanks in advance,
Karthick

Post #1426230
Posted Monday, March 4, 2013 7:20 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 11:09 AM
Points: 20,806, Visits: 32,738
Best way to determine this is to setup a test environment and do it both ways. Using a default will alleviate the need for the developers to code for inserting the current date

Just remember, a default is only used if the column isn't included in the INSERT. If it is included and an invalid or simply incorrect date (including NULL if permitted) will prevent the DEFAULT from being inserted.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1426234
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse