Solved

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

Posted on 2006-10-23
7
504 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
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
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

837 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