Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Inserting a 000000 date value in a field

Posted on 2011-02-22
2
Medium Priority
?
684 Views
Last Modified: 2012-05-11
Hello,

I have an ascii file that i am inserting the records into a MS SQL (2008) table.  The Birthdate field is sometimes a valid date in mmddyy format which I am using Substring to put it into yymmdd format for the field in SQL.  The problem is when the date field in the ascii file is all zeros 000000 (mmddyy) Insert script will not run, I get an error saying "Conversion failed when converting date adn/or tiem from character string."  How can I get the ascii date value of 000000 accepted into the SQL date field?  The field in SQL is a date field and allows nulls?

Thanks,
0
Comment
Question by:JohnJMA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
rushShah earned 2000 total points
ID: 34953930
you can use case when like this,

insert into tablename
select case when date='000000' then null else date end as date
from tablename
0
 

Author Closing Comment

by:JohnJMA
ID: 34955385
Thanks, it works great.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question