<?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 call SQL Server stored procedures that have references to linked servers. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601730#M684092</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create the Batch file and call the Batch file in the script with EXECUTE command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please make sure, you need to select below 2 options in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="script_execute.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/53438_script_execute.JPG.jpg" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Feb 2014 20:28:34 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-02-18T20:28:34Z</dc:date>
    <item>
      <title>How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601729#M684091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having trouble calling stored procedures that have references to linked servers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some quick points about my report:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I have a "Refresh" button that calls a macro that executes stored procedures in my SQL Server DB (local) - am using SQL Server 2012 express&lt;/LI&gt;&lt;LI&gt;I have tested this button-- it can correctly connect to my DB and execute any commands or statements I pass on to it&lt;/LI&gt;&lt;LI&gt;If the SQL command(s) I pass references objects in the local db only, it works fine. However, if the stored proc references a linked server, such as the proc below, it does not push through:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;CREATE PROCEDURE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; [dbo].[TriggerDataRefresh]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;AS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; insert into [MyDatabase].[dbo].[MyTable]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; SELECT * FROM [LinkedServerName].[RemoteDatabase].[dbo].[RemoteTable]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Executing the stored procedure via Sql Server Management Studio or my IDE (DBeaver) using the credentials I use in my QV report works fine too&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, I am still using the personal edition so not sure if this is a limitation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 14:32:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601729#M684091</guid>
      <dc:creator />
      <dc:date>2014-02-18T14:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601730#M684092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create the Batch file and call the Batch file in the script with EXECUTE command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please make sure, you need to select below 2 options in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="script_execute.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/53438_script_execute.JPG.jpg" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 20:28:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601730#M684092</guid>
      <dc:creator />
      <dc:date>2014-02-18T20:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601731#M684093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dathu, thanks for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a moment there I forgot that there are other ways of executing macros in a QV report. I tried your suggestion but was still getting the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After some debugging, I found out that it was my VBScript (I did not include it in the original post) that is at fault, and not Qlikview. WIll be replying to this thread with the solution in case other people encounter a similar problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2014 14:09:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601731#M684093</guid>
      <dc:creator />
      <dc:date>2014-02-19T14:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601732#M684094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out that Qlikview doesn't have a limitation when it comes to executing SQL Server stored procedures. Whether you're executing them from a macro or from the load script it should work as long as you set the timeouts properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For my case above, I was calling a macro from a button in my report. The macro calls on a stored procedure in my local database that references a linked server to another database. Executing the stored procedure in IDEs works fine, but it returns a "query timeout error" when executed inside Qlikview or from a .vbs file in my local system. I observed later on that it takes exactly 30 seconds for the error to appear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After much debugging, found that it's a problem with the remote database server and my macro itself-- the timeouts were not properly set. Note: The expected runtime of my procedure is around 3 minutes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution:&lt;/P&gt;&lt;P&gt;1.) Properly set the remote login and query timeout in the remote database:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.) Change it via script &lt;A href="http://support.microsoft.com/kb/314530"&gt;http://support.microsoft.com/kb/314530&lt;/A&gt;. Make sure the timeouts are longer than the expected runtime of your stored procedure.&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;sp_configure 'remote login timeout', 3600&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;go &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;reconfigure with override &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;go &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;sp_configure 'remote query timeout', 3600&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;go &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;reconfigure with override &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;go &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;b.) Change it in SQL Server Management Studio. You can see this setting in the Connections tab of your server setting:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;IMG alt="server.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/53490_server.png" style="width: 620px; height: 125px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.) Set the connection timeout in your macro/vbs script. I think the default if you don't set this is 30. Here's a copy of the macro I'm using, slighly edited.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUB PRC_TriggerDataRefresh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set conn = CreateObject("ADODB.Connection")&lt;BR /&gt;conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=&lt;EM&gt;&amp;lt;mydatabase&amp;gt;&lt;/EM&gt;;Data Source=&lt;EM&gt;&amp;lt;myserver&amp;gt;&lt;/EM&gt;;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use Encryption for Data=False;Tag with column collation when possible=False;User ID=&lt;EM&gt;&amp;lt;myusername&amp;gt;&lt;/EM&gt;;Password=&lt;EM&gt;&amp;lt;mypassword&amp;gt;&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;conn.CommandTimeout = 3600 --&amp;gt; I did not have this line previously&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;strSQL="execute [MyDatabase].[dbo].[TriggerDataRefresh]"&lt;/P&gt;&lt;P&gt;objADO.Open&lt;BR /&gt;objADO.BeginTrans&lt;BR /&gt;objADO.Execute strSQL, iAffected&lt;BR /&gt;objADO.CommitTrans&lt;/P&gt;&lt;P&gt;objADO.Close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END SUB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2014 14:29:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601732#M684094</guid>
      <dc:creator />
      <dc:date>2014-02-19T14:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601733#M684095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for posting this.&amp;nbsp; Are you able to pass variable values to a SQL stored procedure?&amp;nbsp; I need to pass 4 values to procedure and cant seem to find anything relating to this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Mar 2014 13:14:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601733#M684095</guid>
      <dc:creator />
      <dc:date>2014-03-24T13:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601734#M684096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried it in this way&lt;/P&gt;&lt;P&gt;But it works only if put the password directly in .&lt;/P&gt;&lt;P&gt;It doesn't work with encrypted password&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have an idea why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Bumin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 07:42:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601734#M684096</guid>
      <dc:creator>bumin</dc:creator>
      <dc:date>2014-03-26T07:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601735#M684097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not in front of my old script, but I'm sure you can..&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SQL exec sp_test &amp;amp; ' ' &amp;amp; varParameter1 &amp;amp; ',' &amp;amp; varParameter2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like I say, not in front of my script, but I'm sure as long as the variable is loaded from the script you can pass it into the exec query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 07:45:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601735#M684097</guid>
      <dc:creator />
      <dc:date>2014-03-26T07:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to call SQL Server stored procedures that have references to linked servers.</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601736#M684098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;I also tried executing Stored procedures containing Link to other SQL server and it dint work, but I found solution for this problem, We have to create 2 Stored procedures to make this thing work and below are the steps&lt;/P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;P&gt;&lt;BR /&gt;1. Create Table in in Actual DB to hold values from Linked server.&lt;BR /&gt;2. Create first Stored procedures to insert data from Linked server to actual DB&amp;nbsp;&lt;BR /&gt;3. Create Stored procedures to fetch data from Table of Actual DB&lt;BR /&gt; Then execute both the stored procedures sequentially in QlikView to get the result.&lt;BR /&gt;&amp;nbsp; Since QliKView can't read data from Stored procedures having Link to other server, This might work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 05:36:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-call-SQL-Server-stored-procedures-that-have-references-to/m-p/601736#M684098</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-27T05:36:24Z</dc:date>
    </item>
  </channel>
</rss>

