<?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: How to pass date value embedded within single quotes to call stored procedure on SQL Server in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357161#M122525</link>
    <description>&lt;P&gt;You cannot pass a Date type within single quotes. You are mixing types. Anything supplied within single quotes is a String (or Varchar/char). A Date is essentially just a complex number type. SQL Server will implicitly convert your date as a String IF it is in a format which it understands.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I suspect that we are missing some information here. If your SP requires a Date class (what the tMap column is set to according to your description), you should be able to supply your data as a Date. If this is the case this should work.....&lt;/P&gt; 
&lt;PRE&gt;TalendDate.parseDate("MM-dd-yyyy",row2.DateValue)&lt;/PRE&gt; 
&lt;P&gt;.... if the DateValue is in the format "MM-dd-yyyy". However, I suspect that your SP may require the date as a String and that the column type of the tMap may be wrong.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Either way, it would be easier to figure this out if you could take a screenshot of your SP component config, your tMap config and your SP.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2017 23:08:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-09-26T23:08:24Z</dc:date>
    <item>
      <title>How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357158#M122522</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am trying to call stored procedure using tJDBCSP component after establishing connection to MSSQLServer using tJDBCConnection.&lt;/P&gt;
&lt;P&gt;The stored procedure expects the argument (date value) to be passed within single quotes as '01-28-2016'.&lt;/P&gt;
&lt;P&gt;I have used tMap to convert the date in string format to date format using&amp;nbsp;TalendDate.parseDate("MM-dd-yyyy",row2.DateValue). This is working as expected. If I use&amp;nbsp;"'"+row2.DateValue+"'" in the tMap with column datatype as String and pass this value to call stored procedure, it throws the error as "Conversion failed when converting date and/or time from character string". The stored procedure is expecting the argument to be in date datatype format embedded within single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions on how to go about this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 21:31:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357158#M122522</guid>
      <dc:creator>mra802003</dc:creator>
      <dc:date>2017-09-26T21:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357159#M122523</link>
      <description>&lt;P&gt;I believe I have seen this before, but can't test my suspicion at the moment. I suspect that you may need to supply the date in the format 'yyyy-MM-dd' or 'yyyyMMdd'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this in your tMap.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"'"+routines.TalendDate.formatDate("yyyyMMdd", TalendDate.parseDate("MM-dd-yyyy",row2.DateValue))+"'"&lt;/PRE&gt;
&lt;P&gt;....or....&lt;/P&gt;
&lt;PRE&gt;"'"+routines.TalendDate.formatDate("yyyy-MM-dd", TalendDate.parseDate("MM-dd-yyyy",row2.DateValue))+"'"&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Sep 2017 22:19:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357159#M122523</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-26T22:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357160#M122524</link>
      <description>&lt;P&gt;This will treat the entire value as string and the requirement is to pass the date within single quotes without converting to string.&lt;/P&gt;
&lt;P&gt;The column datatype in tMap is defined as Date format "MM-dd-yyyy".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I try the way you suggested, I am getting the following error:&lt;/P&gt;
&lt;P&gt;Type mismatch: cannot convert from String to Date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 22:33:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357160#M122524</guid>
      <dc:creator>mra802003</dc:creator>
      <dc:date>2017-09-26T22:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357161#M122525</link>
      <description>&lt;P&gt;You cannot pass a Date type within single quotes. You are mixing types. Anything supplied within single quotes is a String (or Varchar/char). A Date is essentially just a complex number type. SQL Server will implicitly convert your date as a String IF it is in a format which it understands.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I suspect that we are missing some information here. If your SP requires a Date class (what the tMap column is set to according to your description), you should be able to supply your data as a Date. If this is the case this should work.....&lt;/P&gt; 
&lt;PRE&gt;TalendDate.parseDate("MM-dd-yyyy",row2.DateValue)&lt;/PRE&gt; 
&lt;P&gt;.... if the DateValue is in the format "MM-dd-yyyy". However, I suspect that your SP may require the date as a String and that the column type of the tMap may be wrong.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Either way, it would be easier to figure this out if you could take a screenshot of your SP component config, your tMap config and your SP.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 23:08:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357161#M122525</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-26T23:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357162#M122526</link>
      <description>&lt;P&gt;I knew I was mixing two datatypes but wanted to know if there is any work around. I have uploaded the pics of all that you asked for.&lt;/P&gt; 
&lt;P&gt;The error in the attached pic is happening when the data type for input argument column in tMap is defined as string.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Regards&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 720px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lqve.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154261iB66AFC18A8660078/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lqve.png" alt="0683p000009Lqve.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LqzW.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/135016i6A4DDD922ADFDB22/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LqzW.png" alt="0683p000009LqzW.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 897px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lqzf.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139106iE441352A85609A00/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lqzf.png" alt="0683p000009Lqzf.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lqt4.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155337iF8D212A41246DFF1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lqt4.png" alt="0683p000009Lqt4.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lqzk.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/152729i3ECFC523A3DCA767/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lqzk.png" alt="0683p000009Lqzk.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 15:25:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357162#M122526</guid>
      <dc:creator>mra802003</dc:creator>
      <dc:date>2017-09-27T15:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357163#M122527</link>
      <description>&lt;P&gt;The procedure is certainly expecting a Varchar. I believe (but can't test this unfortunately) that the datetime2(7) type is means that the the date is being converted from a Varchar to a DateTime2 to 7 fractions of a second. As such, the implicit conversion is likely failing because you are not supplying enough information in the String.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try making sure your String date looks like below....&lt;/P&gt;&lt;PRE&gt;'2017-09-27 00:00:00.0000000'&lt;/PRE&gt;&lt;P&gt;Essentially just hardcode " 00:00:00:0000000" to the end of your date and wrap it in single quotes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 15:51:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357163#M122527</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-27T15:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357164#M122528</link>
      <description>&lt;P&gt;I tried using the hard coded value as "01-28-2016 00:00:00.0000000" in tFixedFlowInput.&lt;/P&gt;
&lt;P&gt;I tried with the default format as well "&lt;SPAN&gt;YYYY-MM-DD hh:mm:ss[.nnnnnnn]", but no luck.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This value gets embedded in single quotes in tMap.&lt;/P&gt;
&lt;P&gt;I still get the same error message as shown below.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Exception in component tJDBCSP_1&lt;BR /&gt;com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting date and/or time from character string.&lt;BR /&gt;at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;When we execute this stored procedure manually on SQLServer window, we use the command as follows and it returns correct values in two output arguments - FiscalWeek and FiscalYear.&lt;/P&gt;
&lt;P&gt;exec [BizTalk].[MMX_GetFiscalWeekAndYear] '01-28-2016'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 16:15:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357164#M122528</guid>
      <dc:creator>mra802003</dc:creator>
      <dc:date>2017-09-27T16:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357165#M122529</link>
      <description>&lt;P&gt;OK, I completely missed something when you showed me your images. It is difficult to explain this, so I have knocked up an example using a SP similar to yours.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Below is the layout of my job. The tFixedFlowInput simply supplies the date value. I have set it to "2017-09-27". I have NOT added single quotes.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job1.png" style="width: 512px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lr0E.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155114i70E15C505F731B5D/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lr0E.png" alt="0683p000009Lr0E.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;Below is the SP config. The schema has 2 columns; currentDateTime (String) and out1 (Object).&lt;/P&gt; 
&lt;P&gt;out1 is to recieve a datarow, not an idividual value.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job2.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lqxz.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/150324iCDAA2E64B4DADF5E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lqxz.png" alt="0683p000009Lqxz.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Next I have added a tParseRecordSet. This is needed to strip the values from the recordset.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job3.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lr0O.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/128658iC79AAD8602DDD7DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lr0O.png" alt="0683p000009Lr0O.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Note that the "Value" corresponds to the columns output by your SP.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;When I run this, I get the values back correctly.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The bit I was missing (or not really thinking about) was the confusion over single quotes required around the date. Since Talend is passing a known String value (the date) we do not need to supply single quotes. That is handled for us. It was the single quotes causing your error and I presume it was an issue with returning the values correctly that led to you assuming that the single quotes were required.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 16:59:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357165#M122529</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-27T16:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass date value embedded within single quotes to call stored procedure on SQL Server</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357166#M122530</link>
      <description>&lt;P&gt;Thanks a lot. It worked this time.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 17:22:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-pass-date-value-embedded-within-single-quotes-to-call/m-p/2357166#M122530</guid>
      <dc:creator>mra802003</dc:creator>
      <dc:date>2017-09-27T17:22:24Z</dc:date>
    </item>
  </channel>
</rss>

