Solved

How to manipulate data using fso

Posted on 2014-10-13
3
87 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 33

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 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

21 Experts available now in Live!

Get 1:1 Help Now