views:

179

answers:

3

We have an Access application front-end connected to a SQL Server 2000 database. We would like to be able to programmatically export the results of some views to whatever format we can (ideally Excel, but CSV / tab delimited is fine). Up until now we've just hit F11, opened up the view, and hit File->Save As, but we're starting to get results with more than 16,000 results, which can't be exported.

I'd like some sort of server side stored procedure we can trigger that will do this. I'm aware of the sp_makewebtask procedure that does this, however it requires administrative rights on the server, and for obvious reasons we can't give that to everyone.

Any ideas?

A: 

If you wanted to do everything in access you could link the view as a linked table and then using the TransferSpreadsheet method you could export that “table” as a csv file

EDIT:

As you want to do it server side check this out

http://www.mssqltips.com/tip.asp?tip=1633

I have used this before and it worked just fine

Kevin Ross
I'd rather do it on the server side, if I can...
andy
The details on that link appear to be for SQL Server 2005. I tried the first step, enabling xp_cmdshell, and got this response:Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.Server: Msg 15123, Level 16, State 1, Procedure sp_configure, Line 79The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option. Valid configuration options are:
andy
A: 

You may want to look at SSIS - it allows creating server side packages to export data on server side.

Another option is to right-click your database and run through data export wizard (which is using SSIS underneath).

Yet another option is to create command line utility (SQLCMD) to export the data into a flat file.

IMHO
SSIS appears to be something that came after SQL Server 2000, correct? I'm limited to SQL Server 2000 here. Also, BCP doesn't seem to handle records with linefeeds well, so I don't think that's a very good option, either...
andy
BCP is not SSIS. You can use DTS packages (previous version of SSIS)
IMHO
Be very glad you are using DTS instead of SSIS. :)
Praesagus
A: 

Have you used VB or Macros?

  1. Create a local table the looks like the view structure
  2. create a query that deletes the contents of the table
  3. create a query that inserts the contents of the view to the local table
  4. use the "analyze with excel" feature or one of the built in export features
  5. Create a macro (or vba) that runs the first two qrys and the export with a single click

I just tried it with 26k rows and it worked without a problem

HTH

Praesagus