Link to home
Start Free TrialLog in
Avatar of msyed1
msyed1

asked on

Initialize DateTime to 01/01/0001 in MS SQL Server


Hello,
I have a date column defined in SQL Server as Datetime.  Starting out, when I first Insert this row in the table, I want to initialize it to something like 01/01/0001 so it does not default to NULLS.  Please let me know how to do this in VB.Net.  msyed1.
Avatar of dqmq
dqmq
Flag of United States of America image

Set it to zero.

SOLUTION
Avatar of Chris Mangus
Chris Mangus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, you can also change the database default to something else.
Avatar of msyed1
msyed1

ASKER

I like the idea of defining a default for my date columns in my table.  When I do a SP_Columns on my table, I see a COLUMN_DEF.  Can you show me how to assign a default value to the ActiveDate column below.  
CREATE table NewTable
REquestID int Not NUll,
Workflowstep int,
ApprovedId char (1),
ActiveDate DateTime
on Primary
Go
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msyed1

ASKER

Thank you all....