Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-10-23
7
Medium Priority
?
510 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 1000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

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…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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.
Viewers will learn how the fundamental information of how to create a table.

670 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