<?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: DECLARE statement in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/DECLARE-statement/m-p/1821127#M9285</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/81131"&gt;@cooper_yonk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is non Qlik related issue, my suggestions would be the following:&lt;/P&gt;&lt;P&gt;1. To rule out that there is a problem with the driver, user the SQL Management Studio tool to run the script and see if its successful there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. If the script fails it probably show a line where is failing, if not, copy sections of the script from the top to the bottom until you get the error to see at what point fails.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jul 2021 18:00:22 GMT</pubDate>
    <dc:creator>NadiaB</dc:creator>
    <dc:date>2021-07-09T18:00:22Z</dc:date>
    <item>
      <title>DECLARE statement</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/DECLARE-statement/m-p/1819037#M9226</link>
      <description>&lt;P&gt;Could anyone help me as after much googleing ive still not been able to get the below script to work...&lt;/P&gt;&lt;P&gt;I get an error (there are subsequent ones but this is the first one that pops up)&lt;/P&gt;&lt;P&gt;Its connecting to the database through ODBC connection.&amp;nbsp; Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;OleDb error&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Connector reply error: ErrorSource: Microsoft OLE DB Provider for SQL Server, ErrorMsg: Incorrect syntax near ''.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;DECLARE '$(@liststr)' NVARCHAR(MAX) = null;&lt;BR /&gt;SQL WITH [BespokeItem] AS&lt;BR /&gt;(&lt;BR /&gt;SELECT DISTINCT [BespokeDefinition] FROM qlikproject.[dbo].[BespokeFieldItems_VIEW]&lt;BR /&gt;)&lt;BR /&gt;SELECT '$(@liststr)' = COALESCE('$(@liststr)' +'],[','') + [BespokeDefinition]&lt;BR /&gt;FROM [BespokeItem]&lt;/P&gt;&lt;P&gt;DECLARE '$(@liststr2)' NVARCHAR(MAX) = null;&lt;BR /&gt;SQL WITH MAXfieldValues AS&lt;BR /&gt;(&lt;BR /&gt;SELECT DISTINCT [BespokeDefinition], [BespokeDefinition] AS FN FROM qlikproject.[dbo].[BespokeFieldItems_VIEW]&lt;BR /&gt;)&lt;BR /&gt;SELECT '$(@liststr2)' = COALESCE('$(@liststr2)','') +'],MAX([' + [BespokeDefinition] + ']) AS [' + [BespokeDefinition]&lt;BR /&gt;FROM MAXfieldValues ORDER BY [BespokeDefinition]&lt;/P&gt;&lt;P&gt;DECLARE '$(@sql)'&lt;BR /&gt;NVARCHAR(MAX) = N'SELECT [CommonRef],referralref, ' + SUBSTRING('$(@liststr2)',3, LEN('$(@liststr2)')) + ']' +&lt;BR /&gt;' FROM&lt;BR /&gt;(&lt;BR /&gt;SELECT [CommonRef], [ReferralRef], [BespokeDefinition],[BespokeItem]&lt;BR /&gt;FROM qlikproject.[dbo].[BespokeFieldItems_VIEW] where BespokeItem is not null and commonref = 101847733&lt;BR /&gt;) a&lt;BR /&gt;PIVOT&lt;BR /&gt;(&lt;BR /&gt;MAX([BespokeItem])&lt;BR /&gt;FOR [BespokeDefinition] IN ([' + '$(@liststr)' + '] )) AS pvt&lt;BR /&gt;GROUP BY commonref,referralref&lt;BR /&gt;'&lt;/P&gt;&lt;P&gt;Exec sp_executesql '$(@sql)'&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:06:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/DECLARE-statement/m-p/1819037#M9226</guid>
      <dc:creator>cooper_yonk</dc:creator>
      <dc:date>2021-12-10T21:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: DECLARE statement</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/DECLARE-statement/m-p/1821127#M9285</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/81131"&gt;@cooper_yonk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is non Qlik related issue, my suggestions would be the following:&lt;/P&gt;&lt;P&gt;1. To rule out that there is a problem with the driver, user the SQL Management Studio tool to run the script and see if its successful there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. If the script fails it probably show a line where is failing, if not, copy sections of the script from the top to the bottom until you get the error to see at what point fails.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 18:00:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/DECLARE-statement/m-p/1821127#M9285</guid>
      <dc:creator>NadiaB</dc:creator>
      <dc:date>2021-07-09T18:00:22Z</dc:date>
    </item>
  </channel>
</rss>

