Solved

How to manipulate data using fso

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
push and Pull replication 31 46
PowerShell and cisco ios 3 40
Powershell Split 18 27
Powershell Regex Replace Question 5 16
A procedure for exporting installed hotfix details of remote computers using powershell
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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