export sql records to csv file

Posted on 2005-05-16
Last Modified: 2008-02-26
I need to export records from a sql table to a csv file. The recorords are not unique by just 1 value.
It actually needs to values in the record to make it unique.
In other words, there may be 5 names that go by Harry so I need to make sure that the last name is
attached to the correct first name.  Any suggestions on how to go about this.  Write a script?  Create  a dts
package?  Ant thoughts would be greatly appreciated.  I am using SQL (8).
Question by:mhedrick
    LVL 23

    Assisted Solution

    Just Run the Query in Query Analyzer, Select All the Records (output) , Right Click and Choose SAVE AS, it will save your File(Selected Records) as CSV.
    LVL 21

    Accepted Solution

    Create a query that correctly selects the information you want, then create a DTS package that uses that same query to export to CSV


    Select Distinct FirstName, LastName
    From Person

    Then use the DTS wizard, and select "use a query...." in teh appropriate screen

    Author Comment

    Thanks for the quick replies,
    This process needs to be automated into a project so I cannot do the save as,  I wish I could but.
    I want to create a csv file  after a user closes there vb application, then the csv
    will be exported into paradox(4.5).  I can hear the chuckling now.....
    Kevin, is the export to csv a built in funtion in the DTS package.  Can i just tell it to create a csv file
    to a directory on the server.  Any thoughts on performance between dts and script?
    LVL 23

    Expert Comment

    Then you have to use DTS and Schedule a JOB in SQL Server, That JOB will execute your DTS Package.
    LVL 21

    Expert Comment

    DTS and script work in conjunction with each other.  Yes, the DTS wizard has Excel as a destination option.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Via a live example, show how to shrink a transaction log file down to a reasonable size.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now