Solved

Date Field Max Length Issues Importing Flat File

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

758 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

19 Experts available now in Live!

Get 1:1 Help Now