Jump to content

How do I save SQL results to a file?


SiteMaze
 Share

Recommended Posts

How do I save SQL results to a file?

The SQL returns 1000s of records, do I have to loop through each of them and save line by line? Is there a simpler better method of doing it?

Example: This SQL will retun 20,000 lines and I love to save this into a CSV file.

$sql2 = ObjCreate("ADODB.Recordset")
        $sql2.cursorlocation = 3
        $sql2.open ("Select * From Table_Members", $oConnectionObj)
        If Not $sql2.eof Then
            $t_ret = $sql2.Fields(0).Value & "," & $sql2.Fields(1).Value  & "," & $sql2.Fields(2).Value  & "," & $sql2.Fields(3).Value 
            $ret = $ret & $t_ret & @CRLF
        EndIf
        $sql2.close
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...