<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									AugSQL - Acumatica User Group Forums				            </title>
            <link>https://www.augforums.com/forums/augsql/</link>
            <description>Acumatica User Group Forums</description>
            <language>en-US</language>
            <lastBuildDate>Mon, 18 May 2026 06:27:28 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Row Level Security Groups</title>
                        <link>https://www.augforums.com/forums/augsql/row-level-security-groups/</link>
                        <pubDate>Sat, 08 Feb 2025 07:12:51 +0000</pubDate>
                        <description><![CDATA[I haven&#039;t had a chance to test this personally, but a friend sent this to me and he knows his stuff so I&#039;m comfortable posting it here.
Row Level security information gets stored in a compl...]]></description>
                        <content:encoded><![CDATA[<p>I haven't had a chance to test this personally, but a friend sent this to me and he knows his stuff so I'm comfortable posting it here.</p>
<p>Row Level security information gets stored in a complicated format in the Acumatica database so it's hard to report on with SQL.</p>
<p>Here are two SQL Views that can help you to untangle the mystery:</p>
<pre contenteditable="false">CREATE OR ALTER VIEW dbo.RDPViewsUserRelationGroups AS
select
      U.CompanyID,
      U.Username,
      RG.GroupName,
      RG.Description
from Users U
      left outer join RelationGroup RG on RG.CompanyID = U.CompanyID and (
            CONVERT(BIGINT, substring(RG.GroupMask, 1, 4)) &amp; CONVERT(BIGINT, substring(U.GroupMask, 1, 4)) != 0 or
            CONVERT(BIGINT, substring(RG.GroupMask, 5, 4)) &amp; CONVERT(BIGINT, substring(U.GroupMask, 5, 4)) != 0 or
            CONVERT(BIGINT, substring(RG.GroupMask, 9, 4)) &amp; CONVERT(BIGINT, substring(U.GroupMask, 9, 4)) != 0 or
            CONVERT(BIGINT, substring(RG.GroupMask, 13, 4)) &amp; CONVERT(BIGINT, substring(U.GroupMask, 13, 4)) != 0
      )</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<pre contenteditable="false">CREATE OR ALTER VIEW dbo.RDPViewsCustomerRelationGroups AS
select
      BA.CompanyID,
      BA.BAccountID,
      BA.AcctCD,
      BA.AcctName,
      RG.GroupName,
      RG.Description
from Customer C
      inner join BAccount BA on BA.CompanyID = C.CompanyID and BA.BAccountID = C.BAccountID
      left outer join RelationGroup RG on RG.CompanyID = C.CompanyID and (
            CONVERT(BIGINT, substring(RG.GroupMask, 1, 4)) &amp; CONVERT(BIGINT, substring(C.GroupMask, 1, 4)) != 0 or
            CONVERT(BIGINT, substring(RG.GroupMask, 5, 4)) &amp; CONVERT(BIGINT, substring(C.GroupMask, 5, 4)) != 0 or
            CONVERT(BIGINT, substring(RG.GroupMask, 9, 4)) &amp; CONVERT(BIGINT, substring(C.GroupMask, 9, 4)) != 0 or
            CONVERT(BIGINT, substring(RG.GroupMask, 13, 4)) &amp; CONVERT(BIGINT, substring(C.GroupMask, 13, 4)) != 0
      )</pre>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/row-level-security-groups/</guid>
                    </item>
				                    <item>
                        <title>ErrorCode: 406</title>
                        <link>https://www.augforums.com/forums/augsql/errorcode-406/</link>
                        <pubDate>Sat, 15 Jun 2024 15:57:07 +0000</pubDate>
                        <description><![CDATA[So far, this is the only bug that we&#039;ve run into with AugSQL and, at this point, we haven&#039;t been able to reproduce it in a local environment. We&#039;ve only heard of it happening in a couple of ...]]></description>
                        <content:encoded><![CDATA[<p>So far, this is the only bug that we've run into with AugSQL and, at this point, we haven't been able to reproduce it in a local environment. We've only heard of it happening in a couple of Acumatica SaaS environments.</p>
<p> </p>
<p>Here's an example from an actual AugSQL User.</p>
<p> </p>
<p>They can successfully run the following SQL Code without any problems:</p>
<pre contenteditable="false">SELECT *
FROM CustomerClass</pre>
<p> </p>
<p>But, when they try to add a WHERE clause like this:</p>
<pre contenteditable="false">SELECT *
FROM CustomerClass
WHERE CompanyID=2</pre>
<p> </p>
<p>They get this error message</p>
<p>ErrorCode: 406.</p>
3560
<p> </p>
<p>For this particular AugSQL User, they get the error message in Acumatica Version 24.105.0036, but they don't get the error (running the same SQL code) in Acumatica Version 23.207.0025.</p>
<p> </p>
<p>But we couldn't reproduce the error in a local Acumatica 24.105.0036 environment.</p>
<p>So, we're not sure at this point if it's an Acumatica Version problem or a SQL Version problem.</p>
<p> </p>
<p>If you get the ErrorCode: 406. error, please reply to this Discussion Topic with both the Acumatica Version that you're running (ie. 24.105.0036) and the SQL Version that you're running. You can find the SQL Version that you're running by running the following SQL command:</p>
<pre contenteditable="false">SELECT @@Version 'SQL Version'</pre>
3561
<p>You can simply copy and paste the gigantic string that you see and reply to this Discussion Topic with it. It will be something like this:</p>
<p>Microsoft SQL Server 2019 (RTM-GDR) (KB5040986) - 15.0.2116.2 (X64) Jul 2 2024 17:41:57 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 &lt;X64&gt; (Build 19045: )</p>
<p> </p>
<p>The good news is that:</p>
<p>1. So far, this is the only AugSQL bug that we've run into.</p>
<p>2. There is a workaround!</p>
<p> </p>
<p>The workaround is to add the TOP command. If you want to return all records, just pick a really big number that will be larger than the number of records returned.</p>
<p>Something like this:</p>
<pre contenteditable="false">SELECT TOP(999999) *
FROM CustomerClass
WHERE CompanyID=2</pre>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/errorcode-406/</guid>
                    </item>
				                    <item>
                        <title>CREATE OR ALTER Statement</title>
                        <link>https://www.augforums.com/forums/augsql/create-or-alter-statement/</link>
                        <pubDate>Wed, 20 Mar 2024 14:05:33 +0000</pubDate>
                        <description><![CDATA[I just learned about SQL syntax that apparently has been around since SQL Server 2016.
 
Previously, I would use this SQL code to create a VIEW:
DROP VIEW IF EXISTS dbo.MySQLSystemEvent
...]]></description>
                        <content:encoded><![CDATA[<p>I just learned about SQL syntax that apparently has been around since SQL Server 2016.</p>
<p> </p>
<p>Previously, I would use this SQL code to create a VIEW:</p>
<pre contenteditable="false">DROP VIEW IF EXISTS dbo.MySQLSystemEvent
GO
CREATE VIEW dbo.MySQLSystemEvent AS
SELECT 2 AS CompanyID,ID,TenantName,,,Source,EventID,ScreenID,,Details,Properties
FROM SystemEvent</pre>
<p> </p>
<p>The reason for the first two lines is that I want to be able to run the same SQL Code whether the View already exists or not.</p>
<p>But there are two problems with it:</p>
<p>1. I can never remember the DROP VIEW IF EXISTS... part and always have to Google it.</p>
<p>2. The view gets a new Created date on it which I don't like. I'd like to know the date that the view was originally created.</p>
<p> </p>
<p>Now, with my new discovery (that has existed for 8 year already apparently), I can write this instead:</p>
<pre contenteditable="false">CREATE OR ALTER VIEW dbo.MySQLSystemEvent AS
SELECT 2 AS CompanyID,ID,TenantName,,,Source,EventID,ScreenID,,Details,Properties
FROM SystemEvent</pre>
<p> </p>
<p>This is awesome! It solves both problems:</p>
<p>1. I can remember CREATE OR ALTER without having to Google it.</p>
<p>2. The Created date on the view doesn't change since an ALTER statement gets run if it already exists.</p>
<p> </p>
<p>I love it!</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/create-or-alter-statement/</guid>
                    </item>
				                    <item>
                        <title>QtyOnHand in INSiteStatus vs. QtyOnHand in INItemStats</title>
                        <link>https://www.augforums.com/forums/augsql/qtyonhand-in-insitestatus-vs-qtyonhand-in-initemstats/</link>
                        <pubDate>Thu, 07 Mar 2024 17:08:20 +0000</pubDate>
                        <description><![CDATA[I&#039;m not sure why, but it seems that INSiteStatus.QtyOnHand is no longer reliable. So, wherever I was using INSiteStatus.QtyOnHand in SQL Views, I&#039;m now using INItemStats.QtyOnHand instead.
...]]></description>
                        <content:encoded><![CDATA[<p>I'm not sure why, but it seems that <span style="text-decoration: underline">INSiteStatus.QtyOnHand</span> is no longer reliable. So, wherever I was using <span style="text-decoration: underline">INSiteStatus.QtyOnHand</span> in SQL Views, I'm now using <span style="text-decoration: underline">INItemStats.QtyOnHand</span> instead.</p>
<p> </p>
<p>I discovered this at a client that had recently upgraded from Acumatica 2022 R1 to Acumatica 2023 R2. The <span style="text-decoration: underline">QtyOnHand</span> numbers looked funny to them and it turned out that the problem was with any SQL Views that were using <span style="text-decoration: underline">INSiteStatus.QtyOnHand</span>.</p>
<p> </p>
<p>The Primary Keys for <span style="text-decoration: underline">INSiteStatus</span> are <span style="text-decoration: underline">CompanyID,InventoryID,SiteID,SubItemID</span></p>
<p>The Primary Keys for <span style="text-decoration: underline">INItemStats</span> are <span style="text-decoration: underline">CompanyID,InventoryID,SiteID</span></p>
<p>I like using <span style="text-decoration: underline">INItemStats</span> better because <span style="text-decoration: underline">SubItemID</span> is related to Sub Items which are rarely used (for good reason) in Acumatica implementations.</p>
<p> </p>
<p>If I do a Trace on a Generic Inquiry in Acumatica 2022 R1 that uses <span style="text-decoration: underline">INSiteStatus</span>, I get something like this:</p>
<pre contenteditable="false">SELECT COUNT( *)
FROM  
WHERE ( . = 2)</pre>
<p> </p>
<p>If I do a Trace on a Generic Inquiry in Acumatica 2023 R2 that uses <span style="text-decoration: underline">INSiteStatus</span>, I get something like this:</p>
<pre contenteditable="false">SELECT COUNT( *)
FROM  
WHERE ( . = 2) AND ( . = 0)</pre>
<p> </p>
<p>So you can see that, in Acumatica 2023 R2, <span style="text-decoration: underline">INSiteStatus</span> is now pulling its data from <span style="text-decoration: underline">INSiteStatusByCostCenter</span> for some reason. I'm not sure why, but it is.</p>
<p>The Primary Keys for <span style="text-decoration: underline">INSiteStatusByCostCenter</span> are <span style="text-decoration: underline">CompanyID,InventoryID,SiteID,SubItemID,CostCenterID</span></p>
<p>I prefer using <span style="text-decoration: underline">INItemStats</span> over over <span style="text-decoration: underline">INSiteStatusByCostCenter</span> because its Primary Keys are simpler.</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/qtyonhand-in-insitestatus-vs-qtyonhand-in-initemstats/</guid>
                    </item>
				                    <item>
                        <title>Sandbox</title>
                        <link>https://www.augforums.com/forums/augsql/sandbox/</link>
                        <pubDate>Thu, 16 Nov 2023 20:31:40 +0000</pubDate>
                        <description><![CDATA[Can we install AugSQL on our sandbox or can we only assign the one license to one installation ID? Do we reassign the license?]]></description>
                        <content:encoded><![CDATA[<p>Can we install AugSQL on our sandbox or can we only assign the one license to one installation ID? Do we reassign the license?</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Andy Sisk</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/sandbox/</guid>
                    </item>
				                    <item>
                        <title>LEFT JOIN vs. INNER JOIN</title>
                        <link>https://www.augforums.com/forums/augsql/left-join-vs-inner-join/</link>
                        <pubDate>Sun, 22 Oct 2023 02:52:56 +0000</pubDate>
                        <description><![CDATA[There are 5 main join types when joining tables together in SQL:

LEFT JOIN
RIGHT JOIN
INNER JOIN
FULL JOIN
CROSS JOIN

 
I personally pretty much always use either LEFT JOIN or INN...]]></description>
                        <content:encoded><![CDATA[<p>There are 5 main join types when joining tables together in SQL:</p>
<ol>
<li>LEFT JOIN</li>
<li>RIGHT JOIN</li>
<li>INNER JOIN</li>
<li>FULL JOIN</li>
<li>CROSS JOIN</li>
</ol>
<p> </p>
<p>I personally pretty much always use either <span style="text-decoration: underline">LEFT JOIN</span> or <span style="text-decoration: underline">INNER JOIN</span> so I'm just going to talk about these 2 join types in this post.</p>
<p>But what's the difference between LEFT JOIN and INNER JOIN?</p>
<p> </p>
<p>First, as a rule, I like to start with the table that is the most detailed, then I join to additional tables to get additional information about a record in the first table.</p>
<p>For example, if we're looking at Customers and we want to get the description of their default payment method, we would start with the <span style="text-decoration: underline">Customers</span> table, then join to the <span style="text-decoration: underline">PaymentMethod</span> table.</p>
<p> </p>
<p>Let's start with this query to see a list of Customers and the ID of each customer's default payment method:</p>
<pre contenteditable="false">SELECT C.CompanyID, B.AcctCD, B.AcctName,
	C.BAccountID, C.CustomerClassID, C.DefPaymentMethodID
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
WHERE C.CompanyID=2
ORDER BY B.AcctCD</pre>
3363
<p> </p>
<p>Notice in the previous screenshot that there are 126 customers and 2 of the customers in the screenshot have an empty <span style="text-decoration: underline">DefPaymentMethodID</span>.</p>
<p>Let's make sure that those are the only 2 customers with an empty <span style="text-decoration: underline">DefPaymentMethodID</span> value with this query where we check for a NULL (empty) <span style="text-decoration: underline">DefPaymentMethodID</span>:</p>
<pre contenteditable="false">SELECT C.CompanyID, B.AcctCD, B.AcctName,
	C.BAccountID, C.CustomerClassID, C.DefPaymentMethodID
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
WHERE C.CompanyID=2 AND C.DefPaymentMethodID IS NULL
ORDER BY B.AcctCD</pre>
3359
<p> </p>
<p>Yep, looks like there are only 2 customers with a NULL (empty) <span style="text-decoration: underline">DefPaymentMethodID</span>.</p>
<p>Let's check the first customer (ABARTENDE) to make sure that it really doesn't have a default payment method:</p>
3360
<p>Yep, no default payment method.</p>
<p> </p>
<p>Ok, now, back to LEFT JOIN vs. INNER JOIN.</p>
<p>If we do a LEFT JOIN to the <span style="text-decoration: underline">PaymentMethod</span> table so we can get the Payment Method description from the <span style="text-decoration: underline">PaymentMethod.Descr</span> field, then we'll still get all 126 customer records, but we'll get NULL (empty) values in the <span style="text-decoration: underline">PaymentMethod.Descr</span> field for customers that don't have a default payment method.</p>
<p>Note the results in the following query. There are still 126 records and those same 2 customers don't have values in the <span style="text-decoration: underline">PaymentMethod.Descr</span> field.</p>
<pre contenteditable="false">SELECT C.CompanyID, B.AcctCD, B.AcctName,
	C.BAccountID, C.CustomerClassID,
	C.DefPaymentMethodID, P.Descr
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
LEFT JOIN PaymentMethod P
	ON C.CompanyID=P.CompanyID
	AND C.DefPaymentMethodID=P.PaymentMethodID
WHERE C.CompanyID=2
ORDER BY B.AcctCD</pre>
3361
<p> </p>
<p>But, if we change LEFT JOIN to INNER JOIN when joining to <span style="text-decoration: underline">PaymentMethod</span> like this:</p>
<pre contenteditable="false">SELECT C.CompanyID, B.AcctCD, B.AcctName,
	C.BAccountID, C.CustomerClassID,
	C.DefPaymentMethodID, P.Descr
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
INNER JOIN PaymentMethod P
	ON C.CompanyID=P.CompanyID
	AND C.DefPaymentMethodID=P.PaymentMethodID
WHERE C.CompanyID=2
ORDER BY B.AcctCD</pre>
3362
<p> </p>
<p>Then we can see that only 124 records are returned and the 2 customers that don't have a default payment method aren't included in the results, that's why there are only 124 records (126 minus 2).</p>
<p> </p>
<p>So, what's the difference between LEFT JOIN and INNER JOIN?</p>
<p><span style="text-decoration: underline">LEFT JOIN</span> return all records from the first table, regardless of whether or not they have a match in the second table.</p>
<p><span style="text-decoration: underline">INNER JOIN</span> only returns records that exist in both the first table and the second table.</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/left-join-vs-inner-join/</guid>
                    </item>
				                    <item>
                        <title>Joining Tables Together</title>
                        <link>https://www.augforums.com/forums/augsql/joining-tables-together/</link>
                        <pubDate>Sun, 22 Oct 2023 01:56:36 +0000</pubDate>
                        <description><![CDATA[Joining tables together in SQL is like doing a VLOOKUP in Excel.
 
In general, when doing a join, you want to include all of the columns that are in the primary key of the table that you a...]]></description>
                        <content:encoded><![CDATA[<p>Joining tables together in SQL is like doing a VLOOKUP in Excel.</p>
<p> </p>
<p>In general, when doing a join, you want to include all of the columns that are in the primary key of the table that you are joining to.</p>
<p> </p>
<p>When you look at the <span style="text-decoration: underline">Customer</span> Data Access Class (DAC) in Acumatica, it automatically gets the Customer ID and Customer Name for you.</p>
<p>In the database though, Customer ID and Customer Name are in the <span style="text-decoration: underline">BAccount</span> table which stores IDs and Names for Customers, Vendors, Employees, and Branches.</p>
<p> </p>
<p>Since Customer ID and Customer Name are in the <span style="text-decoration: underline">BAccount</span> table, we need to join from <span style="text-decoration: underline">Customer</span> to <span style="text-decoration: underline">BAccount</span> to get that info.</p>
<p>Since <span style="text-decoration: underline">BAccount</span> is the table that we're joining to, then we need to know which columns are in the primary key.</p>
<p>We can find out which columns are in the primary keys by looking at the <span style="text-decoration: underline">COLUMN_NAME</span> column in the following query:</p>
<pre contenteditable="false">sp_pkeys 'BAccount'</pre>
3351
<p> </p>
<p>As you can see in the previous screenshot, <span style="text-decoration: underline">CompanyID</span> and <span style="text-decoration: underline">BAccountID</span> are in the primary key, so we need to include both of those columns when joining to the <span style="text-decoration: underline">BAccount</span> table.</p>
<p> </p>
<p>Spoiler alert: <span style="text-decoration: underline">CompanyID</span> is pretty much always in the primary key, just like we pretty much always need to include <span style="text-decoration: underline">CompanyID</span> when querying the database as discussed in this post:</p>
<p><a href="https://www.augforums.com/forums/augsql/your-first-select-statement-and-always-using-companyid" target="_blank" rel="noopener">https://www.augforums.com/forums/augsql/your-first-select-statement-and-always-using-companyid</a></p>
<p> </p>
<p>I'm going to start from the <span style="text-decoration: underline">Customer</span> table and join to the <span style="text-decoration: underline">BAccount</span> table using a LEFT JOIN. For the first column, we need to use the ON statement, then use the AND statement for every column after that.</p>
<p>I like putting each column on a separate line because I think it's easier to read that way. But you can put them all on one line if you want.</p>
<p>Also, when doing joins, we then need to reference the table whenever we're referencing a column from that table. In order to make it less "wordy" so we don't have to repeat long table names every time, we can put a short alias after each table. I try to use just one letter whenever possible to make the alias as short as possible. I'll use C for <span style="text-decoration: underline">Customer</span> and B for <span style="text-decoration: underline">BAccount</span>.</p>
<pre contenteditable="false">SELECT *
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
WHERE C.CompanyID=2</pre>
3354
<p> </p>
<p>SELECT * means that we're getting all columns from both tables. If we only want the <span style="text-decoration: underline">AcctCD</span> and <span style="text-decoration: underline">AcctName</span> columns from the <span style="text-decoration: underline">BAccount</span> table, but all columns from the <span style="text-decoration: underline">Customer</span> table, then we can change SELECT * to SELECT B.AcctCD, B.AcctName, C.* like this:</p>
<pre contenteditable="false">SELECT B.AcctCD, B.AcctName, C.*
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
WHERE C.CompanyID=2</pre>
3355
<p> </p>
<p>We can also alias the column names. Since <span style="text-decoration: underline">AcctCD</span> is <span style="text-decoration: underline">Customer ID</span> and <span style="text-decoration: underline">AcctName</span> is <span style="text-decoration: underline">Customer Name</span>, we can alias them on the first line of the SELECT like this:</p>
<pre contenteditable="false">SELECT B.AcctCD 'Customer ID', B.AcctName 'Customer Name', C.*
FROM Customer C
LEFT JOIN BAccount B
	ON C.CompanyID=B.CompanyID
	AND C.BAccountID=B.BAccountID
WHERE C.CompanyID=2</pre>
3356]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/joining-tables-together/</guid>
                    </item>
				                    <item>
                        <title>Your first SELECT statement and always using CompanyID</title>
                        <link>https://www.augforums.com/forums/augsql/your-first-select-statement-and-always-using-companyid/</link>
                        <pubDate>Sun, 22 Oct 2023 01:25:37 +0000</pubDate>
                        <description><![CDATA[If you&#039;ve never run a SQL statement before, then I&#039;ve got a great place for you to start. You can start by running this SQL statement:
SELECT *
FROM Company

 
If that was your first SQL sta...]]></description>
                        <content:encoded><![CDATA[<p>If you've never run a SQL statement before, then I've got a great place for you to start. You can start by running this SQL statement:</p>
<pre contenteditable="false">SELECT *
FROM Company</pre>
3345
<p> </p>
<p>If that was your first SQL statement, then congratulations!</p>
<p> </p>
<p>The reason why I like using the <span style="text-decoration: underline">Company</span> table in the first SQL statement is that it's great prep for pretty much every other SQL statement that you'll run.</p>
<p>Why? Because you should pretty much always include <span style="text-decoration: underline">CompanyID</span> (1, 2, 3 in the previous screenshot) when running a query to restrict the data returned to a specific Acumatica Tenant.</p>
<p>Wait, Tenant? Then why isn't it called <span style="text-decoration: underline">TenantID</span> instead of <span style="text-decoration: underline">CompanyID</span>?</p>
<p> </p>
<p>Well, first we need to make sure that we're clear about what a Tenant is in Acumatica.</p>
<p>You can see the Tenant in the drop down on the login screen (1st screenshot) or in the upper right-hand corner of the screen after you've logged into Acumatica (2nd screenshot).</p>
3347
3348
<p> </p>
<p>Why isn't it <span style="text-decoration: underline">TenantID</span> in the database? The Tenant in Acumatica used to be called Company, but they renamed it to Tenant in Acumatica 2018 R1. I noted it here:</p>
<p><a href="https://www.augforums.com/forums/everything-else/instance-vs-tenant-vs-company-vs-branch/" target="_blank" rel="noopener">https://www.augforums.com/forums/everything-else/instance-vs-tenant-vs-company-vs-branch</a></p>
<p> </p>
<p>Even though Acumatica now calls it Tenant on the front-end, they never changed <span style="text-decoration: underline">CompanyID</span> to <span style="text-decoration: underline">TenantID</span> in the database because that would have been a major pain.</p>
<p>So, when you see <span style="text-decoration: underline">CompanyID</span> in the database, just think Tenant.</p>
<p> </p>
<p>That matters because we always need to filter the results from a query by <span style="text-decoration: underline">CompanyID</span> so we only get the data from the Tenant that we're interested in.</p>
<p>Back in that first screenshot, there are 3 Companies (Tenants) listed:</p>
<ul>
<li>1 is the template Tenant. It contains template data like a list of Countries and States, Timezones, etc. So everyone's CompanyID of 1 has the same data.</li>
<li>2 is the first Tenant in your Acumatica database. In my Acumatica demo environment, <span style="text-decoration: underline">SalesDemo</span> is the first Tenant listed.</li>
<li>3 is the next Tenant. In my Acumatica demo environment, <span style="text-decoration: underline">Another Tenant</span> is the second Tenant listed.</li>
</ul>
<p> </p>
<p>So, if we want to see Customer data from the <span style="text-decoration: underline">SalesDemo</span> Tenant, then we need to filter on <span style="text-decoration: underline">CompanyID=2</span> when querying the Customer table:</p>
<pre contenteditable="false">SELECT *
FROM Customer
WHERE CompanyID=2</pre>
3349
<p> </p>
<p>Bottom line, make sure to filter on <span style="text-decoration: underline">CompanyID</span> when using AugSQL to query your Acumatica database.</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/your-first-select-statement-and-always-using-companyid/</guid>
                    </item>
				                    <item>
                        <title>Version 1.1.0</title>
                        <link>https://www.augforums.com/forums/augsql/version-1-1-0/</link>
                        <pubDate>Tue, 17 Oct 2023 01:25:51 +0000</pubDate>
                        <description><![CDATA[Previously, queries were limited to 1 minute, but now the execution limit has been extended to 5 minutes.
In future versions, we&#039;d like to make the execution limit a user-defined field in a...]]></description>
                        <content:encoded><![CDATA[<p>Previously, queries were limited to 1 minute, but now the execution limit has been extended to 5 minutes.</p>
<p>In future versions, we'd like to make the execution limit a user-defined field in a preferences screen. If you think that would be a good idea, you can vote on that idea here:</p>
<p><a href="https://www.augforums.com/forums/augsql/user-defined-execution-timeout-setting/" target="_blank" rel="noopener">https://www.augforums.com/forums/augsql/user-defined-execution-timeout-setting</a></p>
<p> </p>
<p>If a query exceeds 5 minutes, you'll get the following message:</p>
<p>Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.</p>
3326
<p> </p>
<p>You can download AugSQL here:</p>
<p><a href="https://www.augforums.com/lesson/downloading-augsql/" target="_blank" rel="noopener">AugForums.com/Lesson/Downloading-AugSQL</a></p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/version-1-1-0/</guid>
                    </item>
				                    <item>
                        <title>User-Defined Execution Timeout Setting</title>
                        <link>https://www.augforums.com/forums/augsql/user-defined-execution-timeout-setting/</link>
                        <pubDate>Tue, 17 Oct 2023 01:24:50 +0000</pubDate>
                        <description><![CDATA[In version 1.1.0, we extended the execution timeout from 1 minute to 5 minutes, but we&#039;d like to create an AugSQL Preferences screen where you can set your own preference for the execution t...]]></description>
                        <content:encoded><![CDATA[<p>In version 1.1.0, we extended the execution timeout from 1 minute to 5 minutes, but we'd like to create an <span style="text-decoration: underline">AugSQL Preferences</span> screen where you can set your own preference for the execution timeout (in minutes).</p>
<p>If you think that's a good idea, then please "like" this Discussion Topic to vote on it.</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/user-defined-execution-timeout-setting/</guid>
                    </item>
							        </channel>
        </rss>
		