﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Manifold Community Site: vbscript to run SQL on a table object?</title><link>http://95.79.92.2:8080/forum/t164909</link><description>Manifold Community Site thread</description><image><url>http://95.79.92.2:8080/forum/images/img-logo.png</url><title>Manifold Community Site: vbscript to run SQL on a table object?</title><link>http://95.79.92.2:8080/forum/t164909</link></image><item><title>RE: vbscript to run SQL on a table object?</title><link>http://95.79.92.2:8080/forum/t164909#164910</link><description>&lt;P&gt;If, in a VBscript, I run an SQL SELECT on a table in my (Manifold 9) project, the result is a table object.&lt;/P&gt;&lt;P&gt;Eg:&lt;/P&gt;&lt;P class='code'&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span class=k&gt;Set&lt;/span&gt;&amp;#160;app&amp;#160;=&amp;#160;Manifold.Application&lt;/P&gt;&lt;P class='code'&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span class=k&gt;Set&lt;/span&gt;&amp;#160;db&amp;#160;=&amp;#160;app.GetDatabaseRoot()&amp;#160;&amp;#160;&lt;span class=c&gt;&amp;#39;&amp;#160;the&amp;#160;opened&amp;#160;MAP&amp;#160;file&lt;/span&gt;&lt;/P&gt;&lt;P class='code'&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;sql&amp;#160;=&amp;#160;&lt;span class=s&gt;&amp;quot;SELECT&amp;#160;*&amp;#160;FROM&amp;#160;TableA&amp;#160;WHERE&amp;#160;...)&amp;#160;;&amp;quot;&lt;/span&gt;&lt;/P&gt;&lt;P class='code'&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span class=k&gt;Set&lt;/span&gt;&amp;#160;TableB&amp;#160;=&amp;#160;db.Run(sql)&lt;/P&gt;&lt;P&gt;Now if I want to run some SQL on TableB, how do I reference TableB in the SQL string?&lt;/P&gt;&lt;P&gt;I suppose I could include an &amp;quot;INTO TableB&amp;quot; clause in my first SQL string, which would create a table which I could query as usual, but I was wondering if there was a way to query the TableB object directly.  (There does not seem to be a &amp;quot;query&amp;quot; method for the Table object in the API documentation!)&lt;/P&gt;</description><dc:creator>menicoll</dc:creator><comments>http://95.79.92.2:8080/forum/t164909#164910</comments><guid>http://95.79.92.2:8080/forum/t164909#164910</guid><pubDate>Fri, 23 May 2025 00:35:41 GMT</pubDate></item><item><title>RE: vbscript to run SQL on a table object?</title><link>http://95.79.92.2:8080/forum/t164909#164911</link><description>&lt;P&gt;Easy: just write your sql string to use the table your SELECT creates.  An SQL expression that returns a table can be used anywhere a table can be used.&lt;/P&gt;&lt;P&gt;Suppose you have a [Mexico Table] with a bunch of fields, one of which is a Population field. What you&amp;#39;re asking is conceptually the same as doing:&lt;/P&gt;&lt;P class='code'&gt;&lt;span class=k&gt;SELECT&lt;/span&gt;&amp;#160;*&amp;#160;&lt;span class=k&gt;INTO&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[TableB]&lt;/span&gt;&amp;#160;&lt;span class=k&gt;FROM&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[Mexico&amp;#160;Table]&lt;/span&gt;;&lt;/P&gt;&lt;P class='code'&gt;&lt;span class=k&gt;SELECT&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[Population]&lt;/span&gt;&amp;#160;&lt;span class=k&gt;FROM&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[TableB]&lt;/span&gt;;&lt;/P&gt;&lt;P&gt;But you can do that in a single line of SQL:&lt;/P&gt;&lt;P class='code'&gt;&lt;span class=k&gt;SELECT&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[Population]&lt;/span&gt;&amp;#160;&lt;span class=k&gt;FROM&lt;/span&gt;&amp;#160;(&lt;span class=k&gt;SELECT&lt;/span&gt;&amp;#160;*&amp;#160;&lt;span class=k&gt;FROM&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[Mexico&amp;#160;Table]&lt;/span&gt;);&lt;/P&gt;</description><dc:creator>Dimitri</dc:creator><comments>http://95.79.92.2:8080/forum/t164909#164911</comments><guid>http://95.79.92.2:8080/forum/t164909#164911</guid><pubDate>Fri, 23 May 2025 05:22:16 GMT</pubDate></item><item><title>RE: vbscript to run SQL on a table object?</title><link>http://95.79.92.2:8080/forum/t164909#164915</link><description>&lt;P&gt;Thanks, yes that works fine.&lt;/P&gt;&lt;P&gt;It seems odd that a table object in a vbscript cannot be queried directly.&lt;/P&gt;&lt;P&gt;And I can&amp;#39;t see a way of saving a table object as a table component so that I could query it with SQL  E.g. a &amp;quot;SaveAs&amp;quot; method of the table object would be nice!&lt;/P&gt;</description><dc:creator>menicoll</dc:creator><comments>http://95.79.92.2:8080/forum/t164909#164915</comments><guid>http://95.79.92.2:8080/forum/t164909#164915</guid><pubDate>Mon, 26 May 2025 17:49:35 GMT</pubDate></item></channel></rss>