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.
Microsoft SQL Server

Avatar of undefined
Last Comment
msyed1

8/22/2022 - Mon
dqmq

Set it to zero.

SOLUTION
Chris Mangus

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dqmq

BTW, you can also change the database default to something else.
ASKER
msyed1

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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
msyed1

Thank you all....