Solved

How to manipulate data using fso

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

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…
Synchronize a new Active Directory domain with an existing Office 365 tenant
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 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…

770 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