By: Tim Smith | Updated: 2014-06-18 | Comments (6) | Related: > PowerShell
Problem / Solution
SQL Server DBAs and Developers often get flat files that they need to import into SQL Server for queries and data manipulation. You could easily use SSIS to do imports or use the import wizard within SSMS, but this takes time to setup and if you have multiple files it can become a time consuming task. In this video tip, Tim Smith shows how you can use PowerShell to dynamically read the flat file, dynamically create a SQL Server table and then import the data into SQL Server with an easy to use PowerShell function. With this function you can pass parameters to the function and use this to automate the creation and import of flat files. Take a look at this video tip and also read the companion tip to get a step by step explanation and access to the code.
Key Learning Items
- Using PowerShell variables
- Using SQLConnection from PowerShell
- Using SQLCommand from PowerShell
- Running SQL queries and stored procedures from PowerShell
- Dynamically building a table and inserting data into SQL Server from PowerShell
- Creating a PowerShell function
Read Companion Tip
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2014-06-18