Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pille
Starting Member
15 Posts |
Posted - 2011-03-20 : 01:24:26
|
| hello all i wrote already about the same subject but to be honest i just do not understand (i perfectly admit it). the merge and bulk import datas just to one table (at lest i cant read anything how to import in more as one table)i just cant figure it out how to do it. could anybody of you show me the syntax for following example tables (i just need an example so i could extend to my real db)create Database Logsgouse Logscreate table DateSet(DateSetID int not null identity primary key,DateSet date not null,);create table Data(DataID int not null identity primary key,Data date not null,);create table Main(MainID int not null identity primary key,DataID int NOT NULL REFERENCES dbo.Data(DataID),DateSetID int NOT NULL REFERENCES dbo.DateSet(DateSetID),);now the import (not sure is the step correct)bulk insert temp_import from 'c:\logs.log' with (FIELDTERMINATOR = ' ',ROWTERMINATOR = '\n')GOthe content of logs.log01.01.2011 data102.01.2011 data201.01.2011 data303.01.2011 data401.01.2011 data504.01.2011 data4now, as you thought, in table dateset should be written 01.01.201102.01.201103.01.201104.01.2011in the table data data1data2data3data4data5and in the main should stand 1 12 21 33 41 54 4as you can see / no double values will be imported. the database is normalized - so farplease guys, let me be a part of you thought so i could close my "personal" fight with that challenge :-)many thanks to you guys and happy sunday |
|
|
pille
Starting Member
15 Posts |
Posted - 2011-03-21 : 21:59:59
|
| update status i am 1 step further now :-)i run queries like insert into Data(Data)select distinct Data from Temp_Importwhere not exists(select Data from Datawhere Data = Temp_Import.Data)goinsert into DateSet(DateSet)select distinct DateSet from Temp_Importwhere not exists(select DateSet from DateSetwhere DateSet = Temp_Import.DateSet)gothese queries sort out the "double" insert problem. |
 |
|
|
tiffanys110
Starting Member
1 Post |
Posted - 2011-03-21 : 23:47:14
|
| i wrote already about the same subject but to be honest i just do not understand (i perfectly admit it). the merge and bulk import datas just to one table (at lest i cant read anything how to import in more as one table)[url=http://www.acquistareedhardy.com/ed-hardy-negozio.html]ed hardy shop[/url][url=http://www.acquistareedhardy.com/ed-hardy.html]ed hardy[/url] |
 |
|
|
|
|
|