SQLCMD question (extract to csv file)

  • I was asked to create a batch file for a non-techie type so that all they have to do is key in a date range within the batch file (or ask them to key in a date range) where this batch file would be located on the users desktop or possibly a Citrix session and it would query our production database and output a csv file to a network folder.

    One person of the 3 (that would need to run this batch file) has a desktop running Windows XP. Another person has Windows 7. The other person connects to a Citrix session to do her work.

    I do not want to have to install SQL tools (SSMS etc) on all the Citrix servers or the desktop workstations.

    The target server is SQL Server 2008 R2. The resulting csv file needs to have formatted data like so...

    "Joe","Schmo","123"

    "Sydney","Glick","890"

    ...with no headers.

    Every forum post I'm coming across gives really good information on how to accomplish this task on computers that have all of the SQL tools installed where administrators or power users would fire off the batch file manually or with a scheduled task. I'm trying to be security minded and only give these non-techie users access to what they need to just produce the CSV file after keying in a date range.

    My idea was to create a batch file for the users that would fire off a stored procedure that would accept 2 dates the user would key in. That process would then spit out a csv file to a certain network folder.

    I came across this post that stated that Microsoft allows you to download command line tools for SQL Server 2008 here. Is this a solution that could be given to non-technical users?...where you wouldn't have to worry about the security of the production database? If it's not a good solution, what other solution would you use?

    I do not have access to hardware that will stay on 24/7 to install SSRS 2008. I'm not allowed to touch the production database server to add SSRS....red tape won't allow me to. I may have access to hardware in about 5-6 months for SSRS but not now.

    Any suggestions will be greatly appreciated.

    TIA,

    John

  • After installing the command line tools you linked to, a simple batch file or PowerShell script that accepts two parameters and calls bcp.exe to execute a stored procedure should suffice.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply