Solved

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

Posted on 2006-10-23
7
506 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running total between 2 sql tables in Sql 6 50
SQL Server how to use a VARIABLE to link tables in a SQL Script? 3 41
HIghlights of SSIS? 3 45
TDE for SQL Web Edition 1 42
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

752 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