SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
marco kiesewettermarco kiesewetter
SIMPLE ETL
SOLUTION
Extracting,Transforming, Loading
Data From Any System To SQL
Server Right FromYour Desktop.
marco kiesewettermarco kiesewetter
OVERVIEW
 Why use manual ETL from your desktop?
 A common issue to deal with
 Example: Salesforce to SQL - a simple way to load fresh
data
 Recap:What is ETL?
 Extract data from outside source, i.e. Salesforce.com
 Transform data to fit operational needs
 Load data into a data storage system such as a SQL database, data mart or
data warehouse
marco kiesewettermarco kiesewetter
WHY USE MANUAL ETL
 Business Analysts, Financial Analysts and BI Developers run
into two common situations where a manual desktop
upload is needed:
 The data does not yet exist in SQL
 Often it is helpful to get a sample dataset into SQL to test and justify an
new data source that is needed.
 Development using this new data source can begin immediately, even before
the automated ETL job is set up by your IT department
 The data needs to be refreshed off-schedule
 Many ETL jobs run once or twice a day. If an extra refresh is needed at
times, a manual upload of ‘fresh’ data can be the quickest way
marco kiesewettermarco kiesewetter
A COMMON ISSUE TO DEAL WITH
One of the most common issues is the formatting
of the raw data
 Field delimiters & row delimiters may not be standard
 The use of quotations and commas in text fields can cause delimiter
recognition to fail
 SQL Server does only support CSV upload if the data is in a specific
format
 Salesforce row delimiters are not recognized
 Quotes only work if all fields in a column are enclosed in quotes
marco kiesewettermarco kiesewetter
SALESFORCE TO SQL - A SIMPLE WAY
TO LOAD FRESH DATA
Example
marco kiesewettermarco kiesewetter
AUTOMATION & SIMPLICITY
Requirement:
 Automation – very little manual effort
 Simplicity – anyone can run the update
marco kiesewettermarco kiesewetter
STEP 1: THE EXTRACT FILE
Download the Salesforce report results you want
to upload
 Download as CSV
 Save in an accessible network path
 The SQL server has to be able to access it.
 Use a filename that does not change
 Avoid dates etc. in the file name.
 Scripts will access this filename in this folder. For an update simply
overwrite this file.
marco kiesewettermarco kiesewetter
STEP 2: STANDARDIZE THE FILE
 Now we are usingWindows PowerShell to prepare the csv for upload
 Often we will have commas in comments or other text fields.We should change the
field delimiter to a different symbol.The pipe “|” is a good option.
 First we will need change all existing pipes to something else in order to make the
pipe symbol unique as field delimiter.
 In the example below I simply remove the pipes by replacing them with an empty
string, they can be replaced with anything else, though.
# Define the file but note that I do not add “.csv”
$csvfile = 'serverfoldersalesforceExtract'
# Now we replace all pipes
get-content ($csvfile + ".csv") | % {$_ -replace "|", ""} |
out-file ($csvfile +" (no Pipes).csv") -force -encoding ascii
marco kiesewettermarco kiesewetter
STEP 2: STANDARDIZE THE FILE
 Next we will change the delimiter and standardize the CSV file:
 The file salesforceExtract (standardized).csv has now all fields in quotes.
Since we do not use commas as delimiters and all pipes were removed
from all text fields, we can safely remove all quotes from the file:
# Make standard CSV but use Pipes as delimiter
Import-csv -path ($csvfile + " (no Pipes).csv") -Delimiter ','
| Export-CSV -path ($csvfile + " (standardized).csv") -
Delimiter '|'
# Remove all Quotes (“)
get-content ($csvfile + " (standardized).csv") | % { $_ -
replace '"',""} | Set-Content ($csvfile + " (upload).csv")
marco kiesewettermarco kiesewetter
STEP 3: UPLOAD TO SQL
 Finally, we upload this prepared CSV to SQL server using
Microsoft SQL Server Management Studio
 For this we use the BULK INSERT command
 In most cases we may upload a complete new data set.The easiest way to
handle this is by deleting the old table and re-creating it.
 Another advantage for doing this is the ease with which new fields can be
added or the variable types of fields can be changed.The new creation of
the table allows for any such adjustments.
 Note that the BULK INSERT functionality is a server-side permission
setting and may need to be activated for your login.
marco kiesewettermarco kiesewetter
STEP 3: UPLOAD TO SQL
 Here is an example SQL
script you can adjust to
fit your needs:
use YourDB
drop table [dbo].[YourTable]
go
create table [dbo].[YourTable](
Field1 nVARCHAR(255) null,
Field2 datetime null,
Field3 float null,
go
bulk insert YourTable
from 'serverfoldersalesfoceExtract
(upload).csv'
With (
fieldterminator = '|',
rowterminator = 'n',
firstrow = 2
)
go
marco kiesewettermarco kiesewetter
STEP 4: PUTTING IT ALLTOGETHER
 Put all the PowerShell commands into a text file with the extension .ps1
 Put the SQL script into a text file with the extension .sql
 Now create a batch script (example below, file extension .bat) that runs
all of the above commands and place everything in the same folder in
which you save your extracted CSV from Salesforce
@echo off
cls
echo Standardizing the CSV file...
powershell.exe -noprofile -ExecutionPolicy ByPass -File “My PowerShell
Script.ps1"
echo.
echo Is SQL Server Management Studio running and logged in to server ?
pause
echo.
echo Loading the SQL Query
“My SQL Script.sql"
marco kiesewettermarco kiesewetter
SIMPLE ETL
Your automated ETL solution is ready.
All you have to do now is saving the report results
under the same file name, run the batch script and
hit “Execute” in SQL Management Studio once it
loaded.
marco kiesewettermarco kiesewetter
THANKYOU
Questions?
Reach out:
https://www.linkedin.com/in/marcokiesewetter

Weitere ähnliche Inhalte

Was ist angesagt?

Mastering your Databases
Mastering your DatabasesMastering your Databases
Mastering your DatabasesSafe Software
 
To Loop or Not to Loop: Overcoming Roadblocks with FME
To Loop or Not to Loop: Overcoming Roadblocks with FMETo Loop or Not to Loop: Overcoming Roadblocks with FME
To Loop or Not to Loop: Overcoming Roadblocks with FMESafe Software
 
1Spatial: Cardiff FME World Tour: Getting started with FME
1Spatial: Cardiff FME World Tour: Getting started with FME1Spatial: Cardiff FME World Tour: Getting started with FME
1Spatial: Cardiff FME World Tour: Getting started with FME1Spatial
 
SAS Visual Process Flows
SAS Visual Process FlowsSAS Visual Process Flows
SAS Visual Process FlowsCraig Trim
 
Workspace Authoring 101: Feature Caching
Workspace Authoring 101: Feature CachingWorkspace Authoring 101: Feature Caching
Workspace Authoring 101: Feature CachingSafe Software
 
A Step-By-Step Guide to Building Codeless Web Apps
A Step-By-Step Guide to Building Codeless Web AppsA Step-By-Step Guide to Building Codeless Web Apps
A Step-By-Step Guide to Building Codeless Web AppsSafe Software
 
Testing in Infrastructure
Testing in InfrastructureTesting in Infrastructure
Testing in InfrastructureMuhammet Arslan
 
How to Develop for Data Transformation with FME Server
How to Develop for Data Transformation with FME ServerHow to Develop for Data Transformation with FME Server
How to Develop for Data Transformation with FME ServerSafe Software
 
What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016Embarcadero Technologies
 
Mule – header collection
Mule – header collectionMule – header collection
Mule – header collectionD.Rajesh Kumar
 
Mule for each scope header collection
Mule for each scope   header collectionMule for each scope   header collection
Mule for each scope header collectionRam Bavireddi
 
Mule for each scope header collection
Mule for each scope header collectionMule for each scope header collection
Mule for each scope header collectionPraneethchampion
 

Was ist angesagt? (14)

Mastering your Databases
Mastering your DatabasesMastering your Databases
Mastering your Databases
 
To Loop or Not to Loop: Overcoming Roadblocks with FME
To Loop or Not to Loop: Overcoming Roadblocks with FMETo Loop or Not to Loop: Overcoming Roadblocks with FME
To Loop or Not to Loop: Overcoming Roadblocks with FME
 
1Spatial: Cardiff FME World Tour: Getting started with FME
1Spatial: Cardiff FME World Tour: Getting started with FME1Spatial: Cardiff FME World Tour: Getting started with FME
1Spatial: Cardiff FME World Tour: Getting started with FME
 
SAS Visual Process Flows
SAS Visual Process FlowsSAS Visual Process Flows
SAS Visual Process Flows
 
Workspace Authoring 101: Feature Caching
Workspace Authoring 101: Feature CachingWorkspace Authoring 101: Feature Caching
Workspace Authoring 101: Feature Caching
 
Ajax
AjaxAjax
Ajax
 
A Step-By-Step Guide to Building Codeless Web Apps
A Step-By-Step Guide to Building Codeless Web AppsA Step-By-Step Guide to Building Codeless Web Apps
A Step-By-Step Guide to Building Codeless Web Apps
 
Testing in Infrastructure
Testing in InfrastructureTesting in Infrastructure
Testing in Infrastructure
 
How to Develop for Data Transformation with FME Server
How to Develop for Data Transformation with FME ServerHow to Develop for Data Transformation with FME Server
How to Develop for Data Transformation with FME Server
 
What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016
 
Mule – header collection
Mule – header collectionMule – header collection
Mule – header collection
 
Aws setup
Aws setupAws setup
Aws setup
 
Mule for each scope header collection
Mule for each scope   header collectionMule for each scope   header collection
Mule for each scope header collection
 
Mule for each scope header collection
Mule for each scope header collectionMule for each scope header collection
Mule for each scope header collection
 

Ähnlich wie Simple ETL Solution - Marco Kiesewetter

Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Netwebhostingguy
 
introductionofssis-130418034853-phpapp01.pptx
introductionofssis-130418034853-phpapp01.pptxintroductionofssis-130418034853-phpapp01.pptx
introductionofssis-130418034853-phpapp01.pptxYashaswiniSrinivasan1
 
SQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesSQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesEduardo Castro
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012Eduardo Castro
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's Newdpcobb
 
My sql with querys
My sql with querysMy sql with querys
My sql with querysNIRMAL FELIX
 
Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssisdeepakk073
 
New features of sql server 2005
New features of sql server 2005New features of sql server 2005
New features of sql server 2005Govind Raj
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
An overview of snowflake
An overview of snowflakeAn overview of snowflake
An overview of snowflakeSivakumar Ramar
 
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docxScanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docxanhlodge
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 

Ähnlich wie Simple ETL Solution - Marco Kiesewetter (20)

Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
 
introductionofssis-130418034853-phpapp01.pptx
introductionofssis-130418034853-phpapp01.pptxintroductionofssis-130418034853-phpapp01.pptx
introductionofssis-130418034853-phpapp01.pptx
 
SQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesSQL Server 2008 Integration Services
SQL Server 2008 Integration Services
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
 
Mysql
MysqlMysql
Mysql
 
Erik_van_Roon.pdf
Erik_van_Roon.pdfErik_van_Roon.pdf
Erik_van_Roon.pdf
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
 
Sql saturday oc 2019
Sql saturday oc 2019Sql saturday oc 2019
Sql saturday oc 2019
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssis
 
New features of sql server 2005
New features of sql server 2005New features of sql server 2005
New features of sql server 2005
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Sq lite
Sq liteSq lite
Sq lite
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
An overview of snowflake
An overview of snowflakeAn overview of snowflake
An overview of snowflake
 
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docxScanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
 
Sql tuning
Sql tuningSql tuning
Sql tuning
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 

Kürzlich hochgeladen

Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Roland Driesen
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Tina Ji
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayNZSG
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in managementchhavia330
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
DEPED Work From Home WORKWEEK-PLAN.docx
DEPED Work From Home  WORKWEEK-PLAN.docxDEPED Work From Home  WORKWEEK-PLAN.docx
DEPED Work From Home WORKWEEK-PLAN.docxRodelinaLaud
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechNewman George Leech
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 

Kürzlich hochgeladen (20)

Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in management
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
DEPED Work From Home WORKWEEK-PLAN.docx
DEPED Work From Home  WORKWEEK-PLAN.docxDEPED Work From Home  WORKWEEK-PLAN.docx
DEPED Work From Home WORKWEEK-PLAN.docx
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through Cartoons
 
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
 

Simple ETL Solution - Marco Kiesewetter

  • 1. marco kiesewettermarco kiesewetter SIMPLE ETL SOLUTION Extracting,Transforming, Loading Data From Any System To SQL Server Right FromYour Desktop.
  • 2. marco kiesewettermarco kiesewetter OVERVIEW  Why use manual ETL from your desktop?  A common issue to deal with  Example: Salesforce to SQL - a simple way to load fresh data  Recap:What is ETL?  Extract data from outside source, i.e. Salesforce.com  Transform data to fit operational needs  Load data into a data storage system such as a SQL database, data mart or data warehouse
  • 3. marco kiesewettermarco kiesewetter WHY USE MANUAL ETL  Business Analysts, Financial Analysts and BI Developers run into two common situations where a manual desktop upload is needed:  The data does not yet exist in SQL  Often it is helpful to get a sample dataset into SQL to test and justify an new data source that is needed.  Development using this new data source can begin immediately, even before the automated ETL job is set up by your IT department  The data needs to be refreshed off-schedule  Many ETL jobs run once or twice a day. If an extra refresh is needed at times, a manual upload of ‘fresh’ data can be the quickest way
  • 4. marco kiesewettermarco kiesewetter A COMMON ISSUE TO DEAL WITH One of the most common issues is the formatting of the raw data  Field delimiters & row delimiters may not be standard  The use of quotations and commas in text fields can cause delimiter recognition to fail  SQL Server does only support CSV upload if the data is in a specific format  Salesforce row delimiters are not recognized  Quotes only work if all fields in a column are enclosed in quotes
  • 5. marco kiesewettermarco kiesewetter SALESFORCE TO SQL - A SIMPLE WAY TO LOAD FRESH DATA Example
  • 6. marco kiesewettermarco kiesewetter AUTOMATION & SIMPLICITY Requirement:  Automation – very little manual effort  Simplicity – anyone can run the update
  • 7. marco kiesewettermarco kiesewetter STEP 1: THE EXTRACT FILE Download the Salesforce report results you want to upload  Download as CSV  Save in an accessible network path  The SQL server has to be able to access it.  Use a filename that does not change  Avoid dates etc. in the file name.  Scripts will access this filename in this folder. For an update simply overwrite this file.
  • 8. marco kiesewettermarco kiesewetter STEP 2: STANDARDIZE THE FILE  Now we are usingWindows PowerShell to prepare the csv for upload  Often we will have commas in comments or other text fields.We should change the field delimiter to a different symbol.The pipe “|” is a good option.  First we will need change all existing pipes to something else in order to make the pipe symbol unique as field delimiter.  In the example below I simply remove the pipes by replacing them with an empty string, they can be replaced with anything else, though. # Define the file but note that I do not add “.csv” $csvfile = 'serverfoldersalesforceExtract' # Now we replace all pipes get-content ($csvfile + ".csv") | % {$_ -replace "|", ""} | out-file ($csvfile +" (no Pipes).csv") -force -encoding ascii
  • 9. marco kiesewettermarco kiesewetter STEP 2: STANDARDIZE THE FILE  Next we will change the delimiter and standardize the CSV file:  The file salesforceExtract (standardized).csv has now all fields in quotes. Since we do not use commas as delimiters and all pipes were removed from all text fields, we can safely remove all quotes from the file: # Make standard CSV but use Pipes as delimiter Import-csv -path ($csvfile + " (no Pipes).csv") -Delimiter ',' | Export-CSV -path ($csvfile + " (standardized).csv") - Delimiter '|' # Remove all Quotes (“) get-content ($csvfile + " (standardized).csv") | % { $_ - replace '"',""} | Set-Content ($csvfile + " (upload).csv")
  • 10. marco kiesewettermarco kiesewetter STEP 3: UPLOAD TO SQL  Finally, we upload this prepared CSV to SQL server using Microsoft SQL Server Management Studio  For this we use the BULK INSERT command  In most cases we may upload a complete new data set.The easiest way to handle this is by deleting the old table and re-creating it.  Another advantage for doing this is the ease with which new fields can be added or the variable types of fields can be changed.The new creation of the table allows for any such adjustments.  Note that the BULK INSERT functionality is a server-side permission setting and may need to be activated for your login.
  • 11. marco kiesewettermarco kiesewetter STEP 3: UPLOAD TO SQL  Here is an example SQL script you can adjust to fit your needs: use YourDB drop table [dbo].[YourTable] go create table [dbo].[YourTable]( Field1 nVARCHAR(255) null, Field2 datetime null, Field3 float null, go bulk insert YourTable from 'serverfoldersalesfoceExtract (upload).csv' With ( fieldterminator = '|', rowterminator = 'n', firstrow = 2 ) go
  • 12. marco kiesewettermarco kiesewetter STEP 4: PUTTING IT ALLTOGETHER  Put all the PowerShell commands into a text file with the extension .ps1  Put the SQL script into a text file with the extension .sql  Now create a batch script (example below, file extension .bat) that runs all of the above commands and place everything in the same folder in which you save your extracted CSV from Salesforce @echo off cls echo Standardizing the CSV file... powershell.exe -noprofile -ExecutionPolicy ByPass -File “My PowerShell Script.ps1" echo. echo Is SQL Server Management Studio running and logged in to server ? pause echo. echo Loading the SQL Query “My SQL Script.sql"
  • 13. marco kiesewettermarco kiesewetter SIMPLE ETL Your automated ETL solution is ready. All you have to do now is saving the report results under the same file name, run the batch script and hit “Execute” in SQL Management Studio once it loaded.
  • 14. marco kiesewettermarco kiesewetter THANKYOU Questions? Reach out: https://www.linkedin.com/in/marcokiesewetter