473,513 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importare txt in SQL

Ecco il mio problema:devo caricare in un database di sql delle tabelle
presenti in file txt la query per caricarle potrebbe essere la
seguente:

create table prova(
codice varchar(22),
rowid varchar(10),
data_open date,
in_attivo int,
in_nota varchar(40),
co_atc varchar(10));
load table prova from 'c:\dbprova.txt' format 'ascii' delimited by ';'
quotes off;
Il file dbprova è strutturato come segue(riporto i primi 5 record):
"0!/{>9V-NF+Y7NFI.@5/;,";"0^;+H_A";25/08/2003;571401;"chinoloni";"J01MA10"
"0!/{>9V-NF+Y7NFI.@5/;,";"1^;+IE@";25/08/2003;;;
"0!@+J*$L4*).)Z[$W^&SQM";"0^.05,{";01/07/2003;900598;"ORTICARIA";"J01DA"
"0!A<H/8*)PY17J8N=#:O()";"0^!7X-#";23/09/2003;337500;"ORTICARIA";"J04AB"
"0!A<H/8*)PY17J8N=#:O(.";"0^|CANI";15/10/2003;489401;"COLICA
ADDOMINALE";"J01MA"
"0!A<H/8*)PY17J8N=#:O)2";"0^/9X#,";04/03/2003;85703;"EDEMA
VULVARE";"G01AA"
"0!A<H/8*)PY17J8N=#:O)2";"0^?R</P";09/09/2003;244501;"AGITAZIONE";"A03FA"
"0!A<H/8*)PY17J8N=#:O<G";"0^/9{-.";04/03/2003;28301;"PRURITO";"J01CA"
Così facendo però mi sballa e non mette in maniera corretta nei vari
campi perchè come si può vedere alcuni campi sono vuoti altri sono
delimitati da virgolette e soprattutto nei primi due campi (codice e
rowid) alcuni caratteri sono proprio il ; .....potete spiegarmi come
aggirare questo problema se è possbile o se ci sono dei tools
precostituiti per fare questo tipo di operazioni?
saluti Emiliano
Jul 20 '05 #1
2 6721
On 9 Jul 2004 05:48:04 -0700, em*****@yahoo.it (Emiliano) wrote:
Ecco il mio problema:devo caricare in un database di sql delle tabelle
presenti in file txt la query per caricarle potrebbe essere la
seguente:


Che DB usa? SQL Server? Se si, prova con BULK INSERT.

Noel
Jul 20 '05 #2
Emiliano (em*****@yahoo.it) writes:
Ecco il mio problema:devo caricare in un database di sql delle tabelle
presenti in file txt la query per caricarle potrebbe essere la
seguente:

create table prova(
codice varchar(22),
rowid varchar(10),
data_open date,
in_attivo int,
in_nota varchar(40),
co_atc varchar(10));
load table prova from 'c:\dbprova.txt' format 'ascii' delimited by ';'
quotes off;
Quello DBMS stai usando? Questo forum è per SQL Server, ma LOAD TABLE
non è un commando in SQL Server.

Anchè, il tipo "date" non esiste in SQL Server.
Il file dbprova è strutturato come segue(riporto i primi 5 record):
"0!/{>9V-NF+Y7NFI.@5/;,";"0^;+H_A";25/08/2003;571401;"chinoloni";"J01MA10"
"0!/{>9V-NF+Y7NFI.@5/;,";"1^;+IE@";25/08/2003;;;
"0!@+J*$L4*).)Z[$W^&SQM";"0^.05,{";01/07/2003;900598;"ORTICARIA";"J01DA"
"0!A<H/8*)PY17J8N=#:O()";"0^!7X-#";23/09/2003;337500;"ORTICARIA";"J04AB"
"0!A<H/8*)PY17J8N=#:O(.";"0^|CANI";15/10/2003;489401;"COLICA
ADDOMINALE";"J01MA"
"0!A<H/8*)PY17J8N=#:O)2";"0^/9X#,";04/03/2003;85703;"EDEMA
VULVARE";"G01AA"
"0!A<H/8*)PY17J8N=#:O)2";"0^?R</P";09/09/2003;244501;"AGITAZIONE";"A03FA"
"0!A<H/8*)PY17J8N=#:O<G";"0^/9{-.";04/03/2003;28301;"PRURITO";"J01CA"


Con SQL Server, si, sarebbe possible di caraicare un file di questo
formato con BCP o BULK INSERT con aiuto di un file di formato. Ma
come credo che non usai SQL Server, non incluso un esempio.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4649
by: STB | last post by:
Salve Ragazzi!!! ho un problema che non riesco a risolvere e spero di riuscirci con il vostro aiuto... dunque.. ho un file csv tipo questo ...
2
4202
by: Marchetto | last post by:
Ciao a tutti, ho trovato molte indicazioni riguardo al seguente problema, ma nessuna ha sortito gli effetti sperati. Ho un db Access con alcune tabelle collegate (file di testo). Da access...
1
2586
by: xiang | last post by:
Salve ho creato una DLL con il linguagio c++, e vorrei usarla con PHP , vorrei cortesemente chiedervi come posso estendere le mie librerie con quella nuova ? Ovvero come posso importare la...
0
240
by: molcaleviATyahoogroupsDOTcom | last post by:
B " H _ KO mafia ! Global Democracy ARTSENU & Fusione Fredda = TRIVOLUZIONE W post OPEC ! ! ! e' SAUDITA - Bin Laden la cosi' detta '' mafia ebraica CFR globalmafia ILLUMINATI '' ....
0
1403
by: molcaleviATyahoogroupsDOTcom | last post by:
KO mafia CFR ILLUMINATI ! Global Democracy TRIVOLUZIONE ARTSENU COLD FUSION W post OPEC ! B '' H _ KO mafia ! Global Democracy ARTSENU & Fusione Fredda = TRIVOLUZIONE W post OPEC ! ! !
0
2124
by: molcaleviATyahoogroupsDOTcom | last post by:
KO mafia CFR ILLUMINATI ! Global Democracy TRIVOLUZIONE ARTSENU COLD FUSION W post OPEC ! B '' H _ KO mafia ! Global Democracy ARTSENU & Fusione Fredda = TRIVOLUZIONE W post OPEC ! ! !
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.