Solved

Date Field Max Length Issues Importing Flat File

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passing Parameter to Stored Procedure 4 25
Create snapshot on MSSQL 2012 3 22
database level memory cache..? 8 18
SQL Function NOT ROUND 9 11
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

825 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