<?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: Writing to SQL DB from Macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553825#M1131995</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;Your suggested lines did work.... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you have any advice/examples of calling stored procedures from QV?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Nov 2013 16:33:28 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-11-21T16:33:28Z</dc:date>
    <item>
      <title>Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553818#M1131988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp; Im successfully updatin an SQL db from Macro. However, when I try to add a datestamp the write fails. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; This is my write command:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sSQL="insert into qlikview_comments (id,user_id,indicator_number, comment,time_added)&amp;nbsp; values (newid(),'" &amp;amp; vuser&amp;nbsp; &amp;amp; "',12345,'" &amp;amp; vcomment&amp;nbsp; &amp;amp; "','" &amp;amp; vtime&amp;nbsp; &amp;amp; "')"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help 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>Wed, 20 Nov 2013 16:54:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553818#M1131988</guid>
      <dc:creator />
      <dc:date>2013-11-20T16:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553819#M1131989</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;Could you give a sample of the result-string eSQL and also a correct sample you expect it to be ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2013 18:26:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553819#M1131989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-20T18:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553820#M1131990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Test it with the normal SQL tool to check the exact syntax of the type. Then show var in the macro via massagebox and modify the string until it match.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2013 18:32:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553820#M1131990</guid>
      <dc:creator>jonasheisterkam</dc:creator>
      <dc:date>2013-11-20T18:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553821#M1131991</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;This is my test SQL string :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;insert into qlikview_comments (id,user_id,indicator_number, comment,time_added)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;values (newid(), 'User1',12345,'this is a test comment',getdate())&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this is my resultset :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;id&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;user_id&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;indicator_number&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;time_added&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;comment&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;83CF78C7-EE27-4C25-940E-A3B5B5F4DFB6&lt;/TD&gt;&lt;TD&gt;User1&lt;/TD&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;2013-11-21 09:40:52.560&lt;/TD&gt;&lt;TD&gt;this is a test comment&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro insert from the document works without the datetime .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this info helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 10:11:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553821#M1131991</guid>
      <dc:creator />
      <dc:date>2013-11-21T10:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553822#M1131992</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 the info, but could you also add the result you expedted ? I mean the string which will work with SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to use the SQL-tool to test (like Jonas mentioned), but perhaps you could test with QV and change the string vtime with a fixed string like f.ex. '2013-11-21 09:40:52.560' or '11-21-2013 09:40:52.560' or '11-21-2013 09:40' or .....&lt;/P&gt;&lt;P&gt;There are many possibilities, but I think it depends on the field 'time_added' and the time/date settings on the server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 11:32:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553822#M1131992</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T11:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553823#M1131993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your reply. I've amended my Macro with these lines before the write statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vdate = "2013-11-21 09:40:52"&lt;/P&gt;&lt;P&gt;MsgBox(vdate) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is showing the correct date,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My write statement now looks like this&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sSQL="insert into qlikview_comments (id,user_id,indicator_number, comment,time_added)&amp;nbsp; values (newid(),'" &amp;amp; vuser&amp;nbsp; &amp;amp; "','" &amp;amp; &lt;STRONG&gt;vdate&lt;/STRONG&gt;&amp;nbsp; &amp;amp; "',12345,'" &amp;amp; vcomment&amp;nbsp; &amp;amp; "')"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is where the macro fails.&amp;nbsp; Im guessing that I need to convert vdate to a datetime variable but not sure how to do this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you can help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 14:36:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553823#M1131993</guid>
      <dc:creator />
      <dc:date>2013-11-21T14:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553824#M1131994</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 suppose next lines will do : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;vdate = (FormatDateTime(date(),2)&amp;nbsp; &amp;amp; " " &amp;amp; FormatDateTime(time() ,4) )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Msgbox vdate&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you have to know (test with trial) how the date and time has to look in the SQL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In our SQL-DB I did not work with 'writing to SQL' but I used 'Stored Procedures' thru QV and I had to format the date as DD/MM/YYYY HH:NN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 16:00:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553824#M1131994</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T16:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553825#M1131995</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;Your suggested lines did work.... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you have any advice/examples of calling stored procedures from QV?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 16:33:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553825#M1131995</guid>
      <dc:creator />
      <dc:date>2013-11-21T16:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553826#M1131996</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;Until now I only used raporting-procedures, no procedures who change data.&lt;/P&gt;&lt;P&gt;But here is a sample of what I used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ODBC CONNECT32 TO SQL_ERP;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* StockList */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;StockList:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SQL EXEC [sql_DB_masterdata].[dbo].[pr_reporting_stocklist]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @id_bu = 1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @id_warehouse = -1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @id_language = 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DISCONNECT;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you can use it, it gave me a boost when I found this in the forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: Could you share your SQL-writing-macro with us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 16:56:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553826#M1131996</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T16:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to SQL DB from Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553827#M1131997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thanks for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my macro for inserting to SQL DB&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sub Update_Comment&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dim sServer, sConn, oConn,oRS&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sServer="myserver"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sConn="provider=sqloledb;data source=" &amp;amp; sServer &amp;amp; ";initial catalog=db_name"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Set oConn = CreateObject("ADODB.Connection")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;oConn.Open sConn, "username", "password"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Set oRS =CreateObject("ADODB.Recordset")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sSQL="insert into db_table (field1)&amp;nbsp; values ("12345")"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ors.open sSQL, oconn&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end sub&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 09:13:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Writing-to-SQL-DB-from-Macro/m-p/553827#M1131997</guid>
      <dc:creator />
      <dc:date>2013-11-22T09:13:48Z</dc:date>
    </item>
  </channel>
</rss>

