<turbo-stream action="update" target="wiki_card"><template>
<h1>Filtering with MS SQL</h1>
<p>Filtering with MS SQL uses standard SQL WHERE clause syntax. MS SQL (Microsoft SQL Server) supports a rich set of operators, functions, and data types for flexible querying.<br><br></p><h2>Filter Syntax Rules</h2><ul><li>MS SQL filters are <strong>case-insensitive</strong> by default (depending on collation settings)</li><li>Use single quotes for string/text values: <code>'text value'</code></li><li><strong>Field names with spaces or special characters must be enclosed in square brackets </strong><strong><code>[Field Name]</code></strong></li><li>Multiple filter criteria can be combined using <code>AND</code> and <code>OR</code> operators</li><li>Date and datetime values should be formatted as strings: <code>'YYYY-MM-DD'</code> or <code>'YYYY-MM-DD HH:MM:SS'</code></li></ul><h2>Examples:&nbsp;</h2><p></p><table class="table table-bordered"><thead><tr><td>Field Name</td><td>Filter</td></tr></thead><tbody><tr><td>CustomerID</td><td>CustomerID = 'CUST001'</td></tr><tr><td>Name</td><td>Name = 'Acme Corporation'</td></tr><tr><td>Order Status</td><td>[Order Status] = 'Completed'</td></tr><tr><td>Description</td><td>Description LIKE '%bicycle%'</td></tr><tr><td>ProductCode</td><td>ProductCode LIKE 'PROD-%'</td></tr><tr><td>Email</td><td>Email LIKE '%@example.com'</td></tr><tr><td>Comments</td><td>Comments IS NULL</td></tr><tr><td>ShipDate</td><td>ShipDate IS NOT NULL</td></tr><tr><td>Notes</td><td>Notes = ''</td></tr><tr><td>ItemNumber</td><td>ItemNumber != ''</td></tr><tr><td>Amount</td><td>Amount &gt; 1000</td></tr><tr><td>ModifiedDate</td><td>ModifiedDate &gt;= DATEADD(day, -7, GETDATE())</td></tr><tr><td>Status</td><td>Status IN ('Active', 'Pending', 'Processing')</td></tr><tr><td>CustomerID</td><td>CustomerID NOT IN ('', 'CUST999', 'TEST001')</td></tr><tr><td>Status</td><td>Status = 'Active' AND Amount &gt; 500</td></tr><tr><td>Product Type</td><td>[Product Type] = 'Hardware' OR [Product Type] = 'Software'</td></tr><tr><td>OrderDate</td><td>OrderDate &gt;= '2025-01-01'</td></tr><tr><td>OrderID</td><td>OrderID IN (SELECT OrderID FROM Orders WHERE OrderDate &gt;= '2025-01-01' AND CustomerID NOT IN ('', 'CUST001', 'CUST002'))</td></tr></tbody></table><br>Important Notes:<p></p><ul><li><strong>Field Names with Spaces</strong>: Always use square brackets <code>[Field Name]</code> when the field name contains spaces or special characters.</li><li><strong>String Values</strong>: Always enclose string values in single quotes <code>'value'</code>.</li><li><strong>Date Format</strong>: Use ISO format <code>'YYYY-MM-DD'</code> or <code>'YYYY-MM-DD HH:MM:SS'</code> for dates.</li><li><strong>NULL vs Empty String</strong>: NULL and empty string ('') are different - use <code>IS NULL</code> for NULL checks, use <code>= ''</code> for empty strings.</li><li><strong>Performance</strong>: Use indexed columns in WHERE clauses for better performance.</li><li><strong>Wildcards</strong>: <code>%</code> matches any sequence of characters, <code>_</code> matches a single character.</li><li><strong>Case Sensitivity</strong>: Depends on database collation settings - default is usually case-insensitive.</li></ul><h2>Troubleshooting Tips:</h2><ul><li>If a filter isn't working as expected, verify the exact field name and data type.</li><li>Test filters directly in SQL Server Management Studio (SSMS) before using in Rapidi.</li><li>Use parentheses to control operator precedence in complex conditions</li><li>When using LIKE, remember that <code>%</code> is a wildcard (not <code>*</code> like in NAV)</li></ul>
</template></turbo-stream>

<turbo-stream action="replace" target="meta_description"><template><meta content='Filtering with MS SQL' id='meta_description' name='description'></template></turbo-stream>
<turbo-stream action="replace" target="meta_keywords"><template><meta content='Filtering with MS SQL SQL syntax SQL operators' id='meta_keywords' name='keywords'></template></turbo-stream>
<turbo-stream action="update" target="meta_title"><template>Filtering with MS SQL - MyRapidi Wiki</template></turbo-stream>
<turbo-stream action="prepend" target="flash"><template></template></turbo-stream>
