Solved

Date Field Max Length Issues Importing Flat File

Posted on 2014-07-28
4
260 Views
Last Modified: 2016-02-11
Hello,

I'm importing a .csv file into SQL Server 2008.  I did a "staging" import setting all fields to varchar(255) to see what data they contained.  Next I ran an SSIS Data Profiling Task (thanks Barry) and got the Column Length Distribution profile.  

The max length on most of the date fields is 21 (as expected because the data has double-quote text qualifiers around all of the values); however, some of the date fields have a max length greater than 21.  

When I look for records where the maximum length exceeds 21 I get results but I don't see what I would expect in the actual data (additional characters).

For instance, if I run this:
select top 100 * from MyTable where len(rtrim(ltrim(MY_DATE1)))='28'

Open in new window


I get results like:
"1986-09-14 00:00:00"

which looks like 21 characters to me.  

I think I'm missing some foundational concept here.  :)  

Can anyone help me out?  

TIA!
0
Comment
Question by:ttist25
[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
4 Comments
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 500 total points
ID: 40225011
<wild guess + shameless plug>

There are likely characters that are not visible there. I'd download a trial of Ultra Edit, which is one of the many super-dooper text editors on the market.   Then open a file in UltraEdit, copy-paste these values in it, and hit Ctrl-H to go into Hex mode and eyeball the hex value of these characters.

Invaluable when dealing with the output of mainframes that will include characters other than what you intend.

Good luck.
0
 
LVL 1

Accepted Solution

by:
ttist25 earned 0 total points
ID: 40225201
Thanks as always Jim.  

I did what you recommended and saw nothing unusual in the hex values.  This caused me to look more closely at what I was doing and I realized the date value I was looking at was for another (very similarly named) date field.  

DOH.  Smack.  

I'm awarding points for pointing me to a new tool which I'm sure I will use in the future.

Thanks!
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40225303
Better you discover it with us then with your co-workers.  Good luck.  -Jim
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

734 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