Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-server-2005 SQL-Server , +
Hi,
 
I have a table as following schema -
 
CREATE TABLE [dbo].[hotel_info](
	[hotel_code] [varchar](20) NOT NULL,
	[images] [varchar](100) NULL
 
) 
 
I have composite key on [hotel_code] and [images] columns .
 
Weekly, I get CSV file for inserting records into table. I have to insert only new records based on composite key from CSV to table.
 
Problem is CSV file has more than 2,00,000 records and there are only few new records weekly to insert.
 
So I am facing some performance degradation issue.
 
Could you please suggest few alternative approaches to tackle this scenario.
 
I have tried Subquery, NOT EXISTS, DISTINCT.
 
I am using MSSQL 2005 edition.
Posted 2-Nov-12 1:28am
Edited 2-Nov-12 1:35am
v2
Comments
Milind Thakkar at 2-Nov-12 6:55am
   
How are you currently doing? Are you passing data to SP?
vikram_shinde at 2-Nov-12 7:06am
   
It's in initial stage so I haven't created SP. Just trying using simple query.
Milind Thakkar at 2-Nov-12 7:28am
   
front-end ? c# ? or no front end ?
vikram_shinde at 2-Nov-12 7:35am
   
c# webapp.
Wants to send csv file with web request.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try using a left join:
INSERT INTO hotel_info (hotel_code, images) 
SELECT A.hotel_code, A.images 
FROM importtable A 
LEFT JOIN hotel_info B ON A.hotel_code = B.hotel_code
                         AND A.images = B.images 
WHERE B.hotel_code IS NULL;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 190
1 PIEBALDconsult 150
2 BillWoodruff 148
3 DamithSL 140
4 Jochen Arndt 125
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 2 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100