<?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 save results from SQL query in data table? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263725#M51483</link>
    <description>&lt;P&gt;markbailey, thank you for reply. I did not know how to get the reference by scripting but after additional searching I found the solution in this &lt;A href="https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/td-p/187001" target="_self"&gt;post&lt;/A&gt;. Thank you all for your time and best regards.&lt;/P&gt;</description>
    <pubDate>Sat, 02 May 2020 15:41:02 GMT</pubDate>
    <dc:creator>lukasz</dc:creator>
    <dc:date>2020-05-02T15:41:02Z</dc:date>
    <item>
      <title>How to save results from SQL query in data table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263445#M51465</link>
      <description>&lt;P&gt;Hello Everybody,&lt;/P&gt;&lt;P&gt;I have the following issue. I want to execute SQL query to get data from database and that is working well. After that I would to save data from query in data table and use that for further processing. Based on ideas from other posts I did a simple assignment to the new variable &lt;EM&gt;dt_TestData&lt;/EM&gt;. I am providing as argument for Data Table the name taken from &lt;EM&gt;QueryName.&lt;/EM&gt; However an error occurs when I want to save data in the new variable. The execution of query works well and the new table with name &lt;EM&gt;Experimental_Data&lt;/EM&gt; opens automatically, but I would like to make the reference to that table. I am overlooking something and not able to notice that. I would appreciate for help how solve this issue. I am using JMP15. One more question, how to disable displaying the table after query execution? Best regards.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data = New SQL Query(
	Connection(
		"ODBC:Description=Datenbank;DRIVER=SQL Server;SERVER=Server;UID=%_UID_%;PWD=%_PWD_%;APP=JMP;DATABASE=EngineeringSupport;"
	),
	QueryName( "Experimental_Data" ),
	Select(
		Column( "Param1", "t1"),
		Column( "Param2", "t1"),
		Column( "Param3", "t1"),
	),
	From( Table( "TestData", Schema( "dbo" ), Alias( "t1" ))),
) &amp;lt;&amp;lt; Run;

dt_TestData = Data Table("Experimental_Data");
Open(dt_TestData);
//further actions with dt_TestData: slicing, joining with other tables, etc.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 20:31:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263445#M51465</guid>
      <dc:creator>lukasz</dc:creator>
      <dc:date>2020-05-01T20:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to save results from SQL query in data table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263512#M51470</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/18506"&gt;@lukasz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last JSL&amp;nbsp; statement&amp;nbsp; is the issue: Open( dt_testData ).&amp;nbsp; If the query ran successfully, the data table is already opened. If you want to make another copy of that table, use Subset. In teh example below dt2 is different table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = dt &amp;lt;&amp;lt; Subset( All Rows, Selected Columns(0), Output Table Name("Big2") );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 May 2020 21:55:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263512#M51470</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2020-05-01T21:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to save results from SQL query in data table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263704#M51475</link>
      <description>&lt;DIV class="jmp-author-username"&gt;gzmorgan0,&lt;/DIV&gt;&lt;DIV class="jmp-author-username"&gt;Thank you for reply! I should have explained that more accurately, the problem is I could not create "dt" variable which would make reference to the data resulted from the query. After the query is executed the new table is created an opened but where can I find (or create) the variable referencing the data? Or it is somehow created and I cannot see/use that? JMP is showing error regarding this line:&lt;/DIV&gt;&lt;DIV class="jmp-author-username"&gt;&lt;STRONG&gt;dt_TestData = Data Table("Experimental_Data");&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="jmp-author-username"&gt;&lt;STRONG&gt;"The data table cannot be found when accessing or evaluating Data Table,&amp;nbsp; Data Table/*###*/("Experimental_Data")"&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="jmp-author-username"&gt;I think the variable &lt;STRONG&gt;dt_TestData &lt;/STRONG&gt;cannot be created in such a way? I would appreciate for further help to solve the issue.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 May 2020 09:35:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263704#M51475</guid>
      <dc:creator>lukasz</dc:creator>
      <dc:date>2020-05-02T09:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to save results from SQL query in data table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263712#M51480</link>
      <description>&lt;P&gt;The variable &lt;STRONG&gt;Data&lt;/STRONG&gt; stores the reference to the data table returned from the query. The function call &lt;STRONG&gt;Data Table( "Experimental Data' )&lt;/STRONG&gt; returns a reference to the open data table Experimental Data. You can send messages to the reference stored in &lt;STRONG&gt;Data&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 02 May 2020 11:39:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263712#M51480</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-05-02T11:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to save results from SQL query in data table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263725#M51483</link>
      <description>&lt;P&gt;markbailey, thank you for reply. I did not know how to get the reference by scripting but after additional searching I found the solution in this &lt;A href="https://community.jmp.com/t5/Discussions/Getting-a-data-table-reference-from-NewSQLQuery-lt-lt-Run/td-p/187001" target="_self"&gt;post&lt;/A&gt;. Thank you all for your time and best regards.&lt;/P&gt;</description>
      <pubDate>Sat, 02 May 2020 15:41:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/263725#M51483</guid>
      <dc:creator>lukasz</dc:creator>
      <dc:date>2020-05-02T15:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to save results from SQL query in data table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/643306#M83992</link>
      <description>&lt;P&gt;That's weird. When I run a query, I cannot send messages directly to the table from the query. I need to first make that table into a data table. See example below. Am I misunderstanding something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Table = New SQL Query(
	Version( 130 ),
	Connection( "ODBC:DSN=yournamehere;" ),
	QueryName( "MyQuery" ),
	Select(
		Distinct,
		Column( "A", "t1" ),
	),
	From(
		Table(
			"some table",
			Schema( "some view" ),
			Alias( "t1" )
		),
		Table(
			"another table",
			Schema( "another view" ),
			Alias( "t2" ),
			Join(
				Type( Left Outer ),
				EQ( Column( "BatchId", "t1" ), Column( "BatchId", "t2" ) )
			)
		)
	)
) &amp;lt;&amp;lt; Run;

// does not work
Close( Table, no save );

// does work
NewTable = Data Table( Table );
Close( NewTable, no save );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ah, I think I have a faint idea now what might have caused this problem:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Table = New SQL Query(
	Version( 130 ),
	Connection( "ODBC:DSN=yournamehere;" ),
	QueryName( "MyQuery" ),
	Select(
		Distinct,
		Column( "A", "t1" ),
	),
	From(
		Table(
			"some table",
			Schema( "some view" ),
			Alias( "t1" )
		),
		Table(
			"another table",
			Schema( "another view" ),
			Alias( "t2" ),
			Join(
				Type( Left Outer ),
				EQ( Column( "BatchId", "t1" ), Column( "BatchId", "t2" ) )
			)
		)
	)
) &amp;lt;&amp;lt; Run Foreground; // this fixed it

// does work
Close( Table, no save );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 11:13:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-results-from-SQL-query-in-data-table/m-p/643306#M83992</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-06-16T11:13:12Z</dc:date>
    </item>
  </channel>
</rss>

