Solved

ASP -> CSV Export Recordset Alternate Options

Posted on 2004-04-07
6
320 Views
Last Modified: 2012-08-13
Hello All

Is there an alternate (better) way to create a CSV file from a recordset  other than:

1. Using Filesystem Object (Don't like because of security issues)
2. Setting content type and asking the users to download a text file from the client browser (don't like because I need to name the text files uniquely and send it to a remote FTP server downstream)
3. Using OSQL or ISQL from SQL Server (tried it but the CSV format seems jumbled)

Regards...
0
Comment
Question by:geoenvi
  • 3
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
Shailesh15 earned 500 total points
ID: 10783063
Since you are using SQl server use BCP utility to export the data into csv file...
Creat stroed procedure in sql server which exposrts query to csv file....
*******************************************************
IF (OBJECT_ID ('dbo.tblBalanceJobCSV') IS NOT NULL)
      DROP PROCEDURE dbo.tblBalanceJobCSV
GO

CREATE PROCEDURE dbo.tblBalanceJobCSV AS
BEGIN
      DECLARE @bcpCommand VARCHAR(8000)

      SET @bcpCommand = 'bcp "SELECT * FROM dbo.tblBalanceJob" queryout'
      SET @bcpCommand = @bcpCommand + ' C:\authors.csv -c -t"," -SSERVERNAME -UUSERNAME -PPASSWORD'
      EXEC master..xp_cmdshell @bcpCommand
            
END
******************************************

Then in ASP call this SP..

conn.Execute ("execute tblBalanceJobCSV")
0
 

Author Comment

by:geoenvi
ID: 10783357
Can you pass  parameters this way?  I used OSQL instead of bcp to export to CSV but the format is not what youy expect.  I postes that particular problem in the DB/SQL area.

0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10783445
You can pass parameters into Stored procedure. & Change the @bcpCommand  string to match.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:geoenvi
ID: 10783523
Yeah tried that too.. Same problem as osql.  the csv format appears jumbled.  Does not work
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10783671
Either its a problem with Settings or data problem. BCP may give problem if special characters are present. Try exporting a simple table with simple fields as a test.
or
Try to export manualy through DTS then you will know if your sql server settings are OK.


0
 
LVL 7

Expert Comment

by:brgivens
ID: 10792692
What security issues in reagrds to FileSystemObject are you concerned about?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 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