|
Hi! I'm completely new to Powershell, but I'm interesting in learning and I have a task that I'd like to automate. Basically, I need to run a series of SQL queries and then export all columns except the leftmost of each result to it's own Excel file with a slightly different set of headings. I'd then need it to save all of the files in a new folder in a directory, with the files titled like '[Date]_[a]_Import.xlsx'. The structure would look like: run SQL a, export to a.xlsx in xxx\[Date]_Imports run SQL b, export to b.xlsx in xxx\[Date]_Imports run SQL c, export to c.xlsx in xxx\[Date]_Imports I can change the queries if removing the left column or reformatting the headings is too much, but I'm curious if this is doable with Powershell. Anyone feel like lending a hand?
|
# ¿ Mar 7, 2012 23:07 |
|
|
# ¿ Apr 24, 2024 22:01 |
|
Sure, just checked and CSVs import fine. Thanks!
|
# ¿ Mar 8, 2012 01:32 |
|
adaz posted:Each SQL query is unique? How many are there? Is there any reason why you need to exclude the leftmost column as opposed to just not querying for that data? Well, the main reason I was hoping to exclude the leftmost column is because the (lengthy) query was written by someone else who didn't comment anything. However, after actually looking at it I found out that it's fairly simple and removing the column wasn't a problem. The only difference between the queries is a "where" clause that's in a few different locations (select a where name='x', select a where name='y', select a where name='z') Since the actual difference between queries is small, how hard would it be to make powershell loop through and replace each instance of x then y then z while still exporting each set of results to a csv?
|
# ¿ Mar 9, 2012 01:45 |