April 3, 2014 at 10:04 pm
I have to check for the duplicate records before inserting the data into sql table.
I am getting the data/records from flat file
So here is the example, if the table column is blank/has some other values i am inserting the multiline text after checking duplicate criteria like below
select * from table1 where column1 like '% [testing query]
in Multiple Lines %'
So if my next record also has the same/similar text it should not insert since a similar record has already been inserted. after checking the duplicate criteria as below
select * from table1 where column1 like '% [testing query]
in Multiple %'
I tried using % operator but it is not checking for the duplicates. Please let me know if i am doing anything wrong or do i have to use any other method to check the duplicates
My column1 data type is Text I even tried to convert the data type to Varchar(max) in the select statement like below but it did not work
select * from table1 where cast(column1 as varchar(max)) like '% [testing query]
in Multiple %'
April 3, 2014 at 10:15 pm
The usual way to do something like that is to do an outer join to the destination table and only insert the values that don't exist there already.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply