Solved

How to manipulate data using fso

Posted on 2014-10-13
3
84 Views
Last Modified: 2014-10-28
I need to transfer data from csv to a sql database. I am using fso, but I have a problem with the date format in the csv.
The string looks like dd month yy, data1, data2. E.g. 05 OCT 14, 27, 54
The database has the date format yyyy-mm-dd

My problem is that I don't know how to swap between date and year inside the string,
0
Comment
Question by:Everlas
3 Comments
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40379269
I would read the data into a string, then use the data parse function of .net to combine into format you need.

you could also do string format (DD MM YY,HH, MM)

Can you post what you have so far?
0
 
LVL 32

Accepted Solution

by:
ste5an earned 500 total points
ID: 40379446
D'oh? fso? fso is short for FileSystemObject under most circumstances.. The date format of your database is irrelevant.
What SQL Server version?

I would load the CSV into a staging table consisting of NVARCHAR() columns and parse it it in T-SQL as

DECLARE @DateLiteral NVARCHAR(255) = '05 OCT 14';

SET LANGUAGE us_english;

SELECT TRY_CONVERT(DATE, @DateLiteral, 6);

Open in new window

0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40379725
SSIS can handle this with a ForEach File Loop, where it processes all files regardless of the name.

Adding PowerShell zone, as I'm guessing this can be done with a PowerShell script.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

706 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

18 Experts available now in Live!

Get 1:1 Help Now