Solved

Date Field Max Length Issues Importing Flat File

Posted on 2014-07-28
4
253 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
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now