0

I'm trying to export a table from sql and save it as an .txt using powershell. However, when I open my .txt file the data is not in table format

This is the format of my .txt file:

Name : Billy Bob Address : Nowhere Rd State : NA Number : 999-999-9999

I would like for my .txt to be written in this format:

Name, Address, State, Number Billy Bob, Nowhere Rd, NA, 999-999-9999 

Or even this format will do, where the space between each column is the tab key

 Name Address State Number Billy Bob Nowhere Rd NA 999-999-9999 
1
  • 1
    Maybe post your current code? Commented Sep 12, 2011 at 14:26

1 Answer 1

3

without your code is not easy help you but if $a is a variable containinng the exported SQL table try this:

$a | export-csv "my.txt" 
Sign up to request clarification or add additional context in comments.

3 Comments

Powershell reads a sql query then output the query into an .txt file
Here is the code that create the .txt file. The file name is try2.txt <p>$DataSet.tables[0] | Out-File C:\example\try2.txt </p> Thanks
use export-csv instead out-file for have a file with comma separed values

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.