<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Deleting rows before inserting into SQL Server 2016 in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Deleting-rows-before-inserting-into-SQL-Server-2016/m-p/2287722#M61280</link>
    <description>&lt;P&gt;You need to think about this in a slightly different way. Try using a tMSSQLRow and just use a query like this....&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;DELETE FROM  [Database].[dbo].[Table] 
WHERE ThatDate &amp;gt; (SELECT TOP 1 ThisDate, ID
FROM [Database].[dbo].[Table]
WHERE ThisDate &amp;lt; CONVERT(DATE, GETDATE()-30)
ORDER BY ThisDate DESC, ID DESC)&lt;/PRE&gt; 
&lt;P&gt;You can parameterise your query however you want using context variables or the globalMap.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Alternatively (if the data comes from a different db to the db having data deleted), you could load your found date into a globalMap (as you mentioned) and then use it in your delete, again in a tMSSqlRow.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 00:30:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-10-10T00:30:03Z</dc:date>
    <item>
      <title>Deleting rows before inserting into SQL Server 2016</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Deleting-rows-before-inserting-into-SQL-Server-2016/m-p/2287721#M61279</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Using this query, I find the date for which I want all rows with a greater date deleted. The table is sorted by this date.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;SELECT TOP 1 ThisDate, ID&lt;BR /&gt;FROM [Database].[dbo].[Table]&lt;BR /&gt;WHERE&amp;nbsp;ThisDate &amp;lt; CONVERT(DATE, GETDATE()-30)&lt;/P&gt;
&lt;P&gt;ORDER BY ThisDate DESC, ID DESC&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This is what I want to do with ThisDate:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;DELETE FROM&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;[&lt;/SPAN&gt;&lt;SPAN&gt;Database&lt;/SPAN&gt;&lt;SPAN&gt;].[dbo].[&lt;/SPAN&gt;&lt;SPAN&gt;Table&lt;/SPAN&gt;&lt;SPAN&gt;]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;WHERE ThatDate &amp;gt; ThisDate&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Despite much searching, I can find no clear explanation on how to do this with tMSSqlOutput or any other component. I&amp;nbsp;can use tSetGlobalVar to pass a value into a query, but which component can execute a delete statement? I really don't care how this can be done, but I want to do it within Talend MDM DI instead of calling a stored procedure.&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 09:11:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Deleting-rows-before-inserting-into-SQL-Server-2016/m-p/2287721#M61279</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T09:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting rows before inserting into SQL Server 2016</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Deleting-rows-before-inserting-into-SQL-Server-2016/m-p/2287722#M61280</link>
      <description>&lt;P&gt;You need to think about this in a slightly different way. Try using a tMSSQLRow and just use a query like this....&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;DELETE FROM  [Database].[dbo].[Table] 
WHERE ThatDate &amp;gt; (SELECT TOP 1 ThisDate, ID
FROM [Database].[dbo].[Table]
WHERE ThisDate &amp;lt; CONVERT(DATE, GETDATE()-30)
ORDER BY ThisDate DESC, ID DESC)&lt;/PRE&gt; 
&lt;P&gt;You can parameterise your query however you want using context variables or the globalMap.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Alternatively (if the data comes from a different db to the db having data deleted), you could load your found date into a globalMap (as you mentioned) and then use it in your delete, again in a tMSSqlRow.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 00:30:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Deleting-rows-before-inserting-into-SQL-Server-2016/m-p/2287722#M61280</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-10T00:30:03Z</dc:date>
    </item>
  </channel>
</rss>

