Solved

Remove quotations/text qualifier from text file when importing to MSSQL using ASP.

Posted on 2006-10-23
7
503 Views
Last Modified: 2008-01-09
I'm using ASP to execute the BULK INSERT statement to import data from an .xls file. The quotation marks are being inputted into the MSSQL DB table. I need to remove the quotation marks (the text qualifier) when importing data from the text file (.csv or .xls file) using ASP. I'm not having any permissions problems.

Please provide the needed code using the variables in the code provided below. The code is needed ASAP so I'm giving it a level of difficult at 250 points.

In the DB, this is what's being imported (with quotations)
"Company1" | "First1" | "Last1" | "Address1"
"Company2" | "First2" | "Last2" | "Address2"

But, this is what I want (without quotations)
Company1 | First1 | Last1 | Address1
Company2 | First2 | Last2 | Address2

Here's my code
Start Code:
<%@ Language=VBScript %>
<% pageTitle = "Bulk Insert Page" %>
<!--#include file="adovbs.inc"-->
<!--#include file="db.asp"-->

<%
dim Conn
dim filePath

filePath = "C:\cold.xls"

set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConString
   
Conn.execute("bulk insert Cold from '"&filePath&"' WITH (FIRSTROW = 2, FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')")

Conn.close
set Conn = nothing
%>

<html>
<title>Bulk Insert Page</title>

<body>
Text File Imported
</body>
</html>

End of Code
0
Comment
Question by:Patriotec
  • 3
  • 2
7 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17792230
>>I need to remove the quotation marks (the text qualifier) when importing data from the text file (.csv or .xls file) using ASP.<<
It can't be done.  Either use DTS or import into a staging table and remove them form there.
0
 
LVL 1

Author Comment

by:Patriotec
ID: 17792349
I meant a web based page, I believe the File Sytem Object can open the file and replace the quotation marks with nothing and then have the corrected info imported into the table or an array that can parse through the file. Just not sure on how this can be done using either method.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17793246
>>I believe the File Sytem Object can open the file and replace the quotation marks with nothing and then have the corrected info imported into the table or an array that can parse through the file<<
That is correct, you can cycle through using the File System object.  However, this does not seem a very efficient way of doing it and further since it is no longer an MS SQL Server question, you should post in a more appropriate Topic Area such as:
http://www.experts-exchange.com/Web/Web_Languages/ASP/
0
 
LVL 1

Author Comment

by:Patriotec
ID: 17797687
ok, how can I use SQL to use DTS from ASP. From what I've read, the DTS can be saved as a stored procedure which I could execute from ASP.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 17797798
>>From what I've read, the DTS can be saved as a stored procedure which I could execute from ASP.<<
No, a DTS package cannot be saved as a stored procedure.  Here is how you can execute DTS from ASP
Execute a package from Active Server Pages (ASP)
http://www.sqldts.com/?207
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

773 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