MyRapidi
MyRapidi

Search our Wiki

Filtering with MS SQL

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.

Filter Syntax Rules

  • MS SQL filters are case-insensitive by default (depending on collation settings)
  • Use single quotes for string/text values: 'text value'
  • Field names with spaces or special characters must be enclosed in square brackets [Field Name]
  • Multiple filter criteria can be combined using AND and OR operators
  • Date and datetime values should be formatted as strings: 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'

Examples: 

Field NameFilter
CustomerIDCustomerID = 'CUST001'
NameName = 'Acme Corporation'
Order Status[Order Status] = 'Completed'
DescriptionDescription LIKE '%bicycle%'
ProductCodeProductCode LIKE 'PROD-%'
EmailEmail LIKE '%@example.com'
CommentsComments IS NULL
ShipDateShipDate IS NOT NULL
NotesNotes = ''
ItemNumberItemNumber != ''
AmountAmount > 1000
ModifiedDateModifiedDate >= DATEADD(day, -7, GETDATE())
StatusStatus IN ('Active', 'Pending', 'Processing')
CustomerIDCustomerID NOT IN ('', 'CUST999', 'TEST001')
StatusStatus = 'Active' AND Amount > 500
Product Type[Product Type] = 'Hardware' OR [Product Type] = 'Software'
OrderDateOrderDate >= '2025-01-01'
OrderIDOrderID IN (SELECT OrderID FROM Orders WHERE OrderDate >= '2025-01-01' AND CustomerID NOT IN ('', 'CUST001', 'CUST002'))

Important Notes:

  • Field Names with Spaces: Always use square brackets [Field Name] when the field name contains spaces or special characters.
  • String Values: Always enclose string values in single quotes 'value'.
  • Date Format: Use ISO format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' for dates.
  • NULL vs Empty String: NULL and empty string ('') are different - use IS NULL for NULL checks, use = '' for empty strings.
  • Performance: Use indexed columns in WHERE clauses for better performance.
  • Wildcards: % matches any sequence of characters, _ matches a single character.
  • Case Sensitivity: Depends on database collation settings - default is usually case-insensitive.

Troubleshooting Tips:

  • If a filter isn't working as expected, verify the exact field name and data type.
  • Test filters directly in SQL Server Management Studio (SSMS) before using in Rapidi.
  • Use parentheses to control operator precedence in complex conditions
  • When using LIKE, remember that % is a wildcard (not * like in NAV)