Note that there are some explanatory texts on larger screens.

plurals
  1. POSSIS OLEDB destination with SQL command (Insert if not exists)
    primarykey
    data
    text
    <p>Ok so according to <a href="http://msdn.microsoft.com/en-us/library/ms141138.aspx" rel="nofollow">Microsoft docs</a> the OLE DB Command Transformation in SSIS does this</p> <blockquote> <p>The OLE DB Command transformation runs an SQL statement for each row in a data flow. For example, you can run an SQL statement that inserts, updates, or deletes rows in a database table.</p> </blockquote> <p>So I want to write some SQL to Insert rows in one of my tables <strong>only IF the record doesn't exists</strong></p> <p>So I tried this but the controls keeps complaining of bad sintaxys</p> <pre><code>IF NOT EXISTS (SELECT * FROM M_Employee_Login WHERE Column1=? AND Column2=? AND Column3=?) INSERT INTO [M_Employee_Login] ([Column1] ,[Column2] ,[Column3]) VALUES (?,?,?) </code></pre> <p>However if I remove the IF NOT EXISTS section (leaving the insert only) the controls says may code is Ok, what am I doing wrong.</p> <p>Is there an easier solution?</p> <p><strong>Update:</strong> BTW My source is a Flat File (csv file)</p> <p><strong>Update since answer:</strong> Just to let people know. I ended up using the <code>OLE DB Command Transformation</code> like I planned cause is better than the <code>OLE DB Destination</code> for this operation. The difference is that I did used the <code>Lookup Component</code> to filter all the already existent records (like the answer suggested). Then use the <code>OLE DB Command Transformation</code> with the <code>Insert SQL</code> that I had in the question and it worked as expected. Hope it helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload