Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Failure of INSERT INTO...

Posted on 2002-06-08
3
Medium Priority
?
221 Views
Last Modified: 2012-06-27
I wrote a simple script using the Jet 4.0 Provider to assist in removing duplicates from a standard ASCII file, while keepng the original line number intact ( hence I could not use a DISTINCT clause ). The SQL statements follow:

; import the text file
'SELECT * INTO [line] FROM [input.txt] IN "" [TEXT;DATABASE=c:\temp]'

;add a line counter
'ALTER TABLE line ADD linecount COUNTER'

;create a temp table with a constraint
"CREATE TABLE temp (line TEXT (50),linecount COUNTER );"
'CREATE UNIQUE INDEX temp ON temp (line)'

'INSERT INTO temp (line,linecount) SELECT * FROM line;'

"SELECT line INTO [Text;DATABASE=c:\temp].[output.txt] FROM temp ORDER BY linecount"


I get no errors, but both the output file and temp table are blank.

If I open Access, create a query and type in the INSERT statment above, it work fine, but Access forces you to confirm 2 warning screens saying it cannot apend all records.

I was wondering if this could be part of the problem and perhaps I need to add something to the script to turn the warnings off.

stan
0
Comment
Question by:stanl
[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 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 7064561
Hi stanl,

Why are you using a script?
You can define a linked table in access to your textfile and issue all needed queries on that linked table.

Removing duplicates could be done by a GroupBy query to select the first line of each unique value and followed by a delete of the non-matching.

Nic;o)
0
 
LVL 9

Accepted Solution

by:
ornicar earned 600 total points
ID: 7064991
If you want to turn the messages off, just use:

DoCmd.SetWarnings False

And to turn them on again:

DoCmd.SetWarnings True

The duplicates will not be added with no message. If this is ok for you, that's fine. I feel it would be better to import into an intermediate table allowing duplicates, then run a check-duplicates query to show these records. Very often it's better to check why there are duplicates and what there are. Just a guess.

0
 

Author Comment

by:stanl
ID: 7065160
As it turned out, if I changed my original OLE Object from the Jet OLEDB Provider to Access.Application the script worked fine.  Since the DoCmd is not part of the Provider Object, that got me thinking about making that change ( but there was never a need to even touch the SetWarnings property.

I agree about holding the duplicates, but the text files are created by 'cut-and-paste' which is subject to slight error.



0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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