How to perform Fuzzy search in a string field. At first, using this new syntax probably feels a little weird because you’re working with objects instead of rows. Hot Network Questions Is there a difference between Rust's `macro_rules!` and Scheme's `syntax-rules`?The following are examples of text searches that use SOQL. And the IN clause is part of that 4,000 characters. As a reminder, if you have one or more selective filters in your SOQL, the query optimizer can use that as the leading filter, so your query will perform well even if you have a non-optimal LastModifiedDate filter defining the upper boundary of a date range. Select count () From ProcessInstance where. The best approach here, if you want to avoid doing the work in Apex, would be to create a formula field (boolean/checkbox) that tells you whether or not a field is blank, and then including that in your query (either WHERE. Don’t use the backslash character in a search except to escape a special character. RecordTypeInfo returned by Case. SOQL vs SQL SOQL. The BETWEEN operator is inclusive: begin and end values are included. So if you work in MS SQL Serve, you use T-SQL. Don't use it as a crutch to avoid learning SOQL -- SOQL is very expressive and robust, and several orders of magnitude faster when doing multiple-object queries, even in the trivial. This works: Map<Id, Account> accounts = new Map<Id, Account> ( [SELECT Id, Name FROM Account]); Because the return type from the SOQL is that of Account. Q. tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num. They are specified in T-SQL statements and make the optimizer select the execution plan based on this hint. These two operators can be combined to test for multiple conditions in a SELECT, INSERT, UPDATE, or DELETE statement. expression IN (value1,value2,. The SQL LIKE Operator. If the category id and the year released is the same for more than one row, then it’s considered a duplicate and. As the name implies, this part of SQL is for writing. SOQL is the basic query language used in Apex, the REST API, etc. Select TargetObjectId, Status From ProcessInstance where TargetObjectId='006g0000003AitI' and Status='Pending' limit 1. In SQL, wildcard characters can be used with the SQL LIKE operator. So the fundamental difference is the lack of support for variable binding. getLimitAggregateQueries() returns. To query the data and get information for both people in one row, you could self join like this: select e1. When combining these conditions, it is important to use parentheses so that the database knows what order to evaluate each condition. 3. MySQL is one of the relational database types, whereas NoSQL is more of a design-based database type with examples like MongoDB, Couch DB, etc. In the Query Editor tab, enter the following SOSL query. The Apex parser first evaluates the local variable in code context before executing the SOQL or SOSL statement. Yes as Jerry said in salesforce there is no such thing like If or case in SOQL rather you can use either where clause and create a particular condition use AND, OR, NOT , or Like to filter over a set of records from a particular object or you need to filter records by iterating them by a loop. The main difference between them is that the WHERE clause is used to specify a condition for filtering records before any groupings are made, while the HAVING clause is used to specify a condition for filtering values from a group. The IN operator returns true if a value is in a set of values or false otherwise. If you've come from a relational database background and are new to Salesforce, this article should give you a beginning comparison between Structure Query Language (SQL) and Salesforce Object Query Language. number : It is a numeric value. CRM(Customer Relationship Management) - Salesforce를 자발적으로 학습하고, 학습한 내용을 비정기적으로 기록합니다. SOQL queries executed in Apex don’t respect user permissions. I believe using selective query like IN is preferable over NOT IN. Apex generally runs in system context; that is, the current user's permissions and field-level security aren’t taken into account during code execution. 4. COUNT (fieldName) COUNT ( fieldName) returns the number of rows that match the filtering conditions and have a non- null value for fieldName. Select Salesforce objects from the product-specific data connector list, and then select Connect. Async SOQL - is there a way to export the result into a . #. Objective In this Salesforce tutorial, we will see SOQL vs SOSL. SQL is a standard language for storing, manipulating, and retrieving data in databases. Use. SELECT fieldList [subquery] [. In the meantime, you can download the SOQL extension from the marketplace. With SQL, the wildcards are: ['%'] A substitute for zero or more characters. SELECT * FROM customers WHERE name != ‘Joe’. Copy value from a picklist in Product to Opportunity via OpportunityLineItems on update or insert. SOQL is Force. Say hello to a faster, more intuitive way to query your data. 53);SOQL および SOSL の概要. 4 min read. Overview # SOQL Builder is available as a part of the Salesforce Extension Pack. SQL requires structured and tabular data and supports complex queries. List<sObject> sobjList = Database. You can also use comparison operators to create complex queries with semi-joins and anti-joins. It is currently in beta version (as of November 22, 2020). When your filter uses != or NOT—which includes using NOT EQUALS/CONTAINS for reports, even if the field is indexed—the Force. query can be used wherever a static SOQL query can be used, such as in regular assignment statements and for loops. I am working on SQL query, I have pre-created SOQL query, I am looking for a way to convert it to SQL query. Syntax. For example, in the clause [ORDER BY fieldOrderByList [ASC | DESC] [NULLS {FIRST | LAST}]] , ASC, DESC, or the NULLS clause cannot be used without. This blog post helps explain SOQL, or the Salesforce Object Query Language, to developers familiar with SQL. As the name implies, this part of SQL is for writing. Also, there doesn't seem to be. First Name. WHERE: is used to check conditions before the aggregation takes place. Faster than SOQL: When if the search expression uses a CONTAINS term. This action enables the query to calculate subtotals so that you don’t have to maintain that logic in your code. All referential cascade actions and constraint checks also must succeed before this trigger fires. The LIKE operator performs a case-insensitive match, unlike the case-sensitive matching in SQL. For other SOQL limits, see SOQL and SOSL Limits in the Salesforce Developer Limits and Allocations Quick Reference. In the Developer Console Query Editor, the History pane displays your last 10 queries for quick reuse. MySQL updates frequently as it is a piece of software. The field expression syntax of the WHERE clause in a SOQL query consists of a field name, a comparison operator, and a value. SOQL Builder and its accompanying language server can help you be more productive while writing SOQL. NoSQL databases allow you to add new attributes and fields, as well as use varied syntax across. Note that the value bound has to be a simple variable reference (e. The difference between the having and where clause in SQL is that the where clause cann ot be used with aggregates, but the having clause can. SOQL applies specific limits to objects and situations in search results. Use aggregate functions in a GROUP BY clause in SOQL queries to generate reports for analysis. In API version 58. Let’s take a close look at the pros and cons of SQL vs. For Example consider the student table given below, ROLL_NO. SELECT Name,Phone FROM Account. Currently serving as a Salesforce Developer at Health Stream in Nashville, TN, Rahul specializes in developing interactive. You use a self join when a table references data in itself. They can be either related or not. sql operators. So Union is much better than the Union All with Distinct in performance-wise. 1. queryWithBinds (string, bindVariablesMap, accessLevel); The Database. You can use the GROUP BY option in a SOQL query to avoid iterating through individual query results. 2. ·. SQL is a standard language that enables the user to design and manage databases. VS Code Extensions. You just have to write the statement ROLLBACK TRANSACTION,. The WHERE clause can contain one or many AND operators. Difference between SOQL and SQL query syntax. Users can also beautify and remove the comments from SQL. 975 3 13 25. I know the outputs will be same for both the queries. name AS owner FROM pets FULL JOIN owners ON pets. csv file or so instead of inserting into target object 1 How to perform SOQL query after retrieving access_token and instance_url via oAuth2 flow?With SQL programming, you can add, modify, search, delete or edit records in the database; it can also optimize and perform maintenance of databases. SOQL and SOSL have distinctive files. SQL databases, also known as relational databases, have been widely used for decades. Aggregate Functions. newInstance (Long) method: Long longtime = System. name FROM Account WHERE name LIKE :entityList. skyvia. Difference between SOQL and SOSL in Salesforce : SOQL returns records from database using SELECT. SOQL injection is a vulnerability in which a user directly controls portions of a SOQL database query. SOQL vs SOSL – Speed. The Salesforce extensions for VS Code include a number of extensions that add a wide range of productivity features to the VS Code user interface. No code required. STATIC VS DYNAMIC? Static SOQL is one which you write in square brackets. ). It supports all the basic programming languages like C, C++, Perl, PHP, Python, and Ruby. SOQL. SOQL nature gives off an impression that it is pretty confined in terms of functionality. SQL, on the other hand, is typically executed in the context of a specific database management system (DBMS). Sr. SQL and SAQL have the following differences in behavior. Calling XmlNode. VS Code Extensions. Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn,. Step 1: Where clause filters data. VS Code Extensions. 3. The LIKE operator in SOQL and SOSL supports escaping of special characters % or _. x in ('a', 'b', 'x') will return true result as x is in the the list of values. 2. The IN operator is a shorthand for multiple OR conditions. So that it will check the Sub-Strings as well. For example, you could use. This post & video explained about to Execute SOQL in Visual Studio Code: From Command Palette (Ctrl+Shift+P) -> Type Execute SOQL and Select “ SFDX: Execute SOQL Query with Currently Selected Text “, results appear in the Output panel as highlighted. Use this if you are using the Microsoft PostgreSQL or MSSQL Extensions since they do not provide a new language ID for VSCode. 2. Community. For SOSL search results with multiple objects, each object is displayed on a separate tab. That type of filtering needs to be done in apex, outside of a query. SQL. SELECT AccountId FROM Event WHERE ActivityDate != null. In SQL, the AND & OR operators are used for filtering the data and getting precise results based on conditions. com SOQL & SQL . Tableau Embedding Playground. SOQL is much simpler and more limited in functionality than SQL. Hive Query Language (HiveQL): HiveQL is a query language for Hive to analyze and process structured data in a Meta-store. The = operator is used with Where Clause in SQL. SQL vs NoSQL:A Performance Comparison. It is a relational database management system that uses SQL. There are advantages and disadvantages to each approach, but from a learner perspective, this difference isn't too. In some circumstances, for example with a. SQL vs NoSQL. In the context of relational databases, an upsert is a database operation that will update an existing row if a specified value already exists in a table, and insert a new row if the specified value doesn’t already exist. We’re thrilled to introduce you to a new, faster way to write SOQL queries! The SOQL Query Builder is a VS Code extension that delivers a rich, intuitive UI for designing and executing queries against your Salesforce data. Use an alternative longer syntax where BETWEEN doesn't work because one or both of the values should not be included e. By default, a new project has a folder scripts/soql that contains an example accounts. SELECT Id, Name, BillingCity FROM Account. Part of the reason for that is because Full Text Search (FTS) is the recommended alternative. An add-in for SQL Server Management Studio and Visual Studio, SQL Prompt strips away the repetition of coding. You can use aggregate functions without using a GROUP BY clause. And the IN clause is part of that 4,000 characters. Relationship queries are similar to SQL joins. vs. Start your 28-day free trial. Sorted by: 11. For example, you could use the AVG () aggregate function to find the average. Select TargetObjectId, Status From ProcessInstance where TargetObjectId='006g0000003AitI' and Status='Pending' limit 1. When you design SOQL relationship queries, there are several limitations to consider. SQL statements are executed one at a time, also known as "non-procedural. When you store the records in the List, you can use that list to manipulate that in the for loop, but you can also use it in other operations at a later time. Drag any table from the left side of the screen to the canvas screen and double-click over it. Description (Long Text Area) I need to get all names which have the word 'Developer' (or any keyword) in the 'Description' Long Text area. In a grouped query, SQL returns a group for null values in a grouped query by default. OrderDetails. today (). SELECT Account__c,Name__c from CustomObject WHERE. I don't know if I can explain it very well, but to me, SQL feels more like I'm looking over an entire forest, whereas SOQL only allows me to look at a few specific trees at a time. 1. Suppose we need to submit the list of all. SOSL is a programmatic way of performing a text-based search against the search index. Usually, we use it with the SELECT. With the SOQL Query Builder, writing, running, and exploring the results of your. Need additional guidance? Bring your questio. If you're looking for the value of a single variable, then it would make sense that the operator would be "equal" to the value of the specified variable, it wouldn't be "IN" the variable as if your query has to sort among a group of records. They are part of standard SQL and work across all database types, making it essential knowledge for all SQL users. Structured Query Language (SQL) เป็นภาษาโปรแกรมสำหรับจัดเก็บและประมวลผลข้อมูลในฐานข้อมูลแบบเชิงสัมพันธ์ ฐานข้อมูลแบบเชิงสัมพันธ์. SQL databases have a predefined structure that requires the data to conform to a specific schema. . Format your SQL. ”. Gaining an understanding of these operators will allow you to write better queries and demonstrate. SOQL doesn’t support all advanced features of the SQL SELECT command. In a way, I guess that SOQL is closer to an Object-Relational Mapper (ORM) like Hibernate (Java) or Doctrine (PHP) than it is to SQL itself. SQL does not change (much), as it is a language. It is NULL. Selection means which rows are to be returned. Indeed a clear explanation, but I find this aspect of SQL confusing/misleading: the SELECT clause actually performs a projection (not selection. Organizations that support data-intensive applications must make many decisions about how to best implement and maintain them. 6,574 5 30 56. See here: SOQL: Performing Query with both LIKE & IN. ACID compliance. The LIMIT clause has no limit in and of itself. 0. By default, a new project has a folder scripts/soql that contains an example accounts. Projection means choosing which columns (or expressions) the query shall return. Unfortunately, SOQL cannot compare a field to another field, so we can't take care of the a. SQL not like statement syntax will be like below. Guess I can use Limits. We can specify multiple conditions in a Where clause to exclude the corresponding rows from an output. Of course, it CAN be used for querying – but it can also be used to create database components. queryWithBinds methods can be used wherever an inline SOQL query. In this blog post, we will guide you on these. While it is commonly used by developers when writing Apex, its uses go far beyond that, allowing both admins and developers to. c) A contact's e-mail address is flagged as per the Email Bounce Management configuration. soql files. SQL statements are much more flexible than GraphQL because (in most cases) the latter will reduce to SQL anyway. Changing the types of these fields is not possible. 3. LastName FROM Contact con LEFT OUTER JOIN Account acc ON con. SObjectType. Find examples of Salesforce SOQL queries compared to SQL queries query: DISTINCT, SELECT, CONNECT, COUNT, UPDATE and others. They can be either related or not. Static or Embedded SQL are SQL statements in an application that do not change at runtime and, therefore, can be hard-coded into the application. Azure Data Factory gives an option to load data incrementally by using an SOQL query, Example bellow: Select COLUMN_1,. The first part of the WHERE clause maps easily between SQL and SOQL. field2 part of your example SQL in the 'equivalent' SOQL. What is the difference between SQL and SOQL? Ask Question Asked 5 years, 10 months ago Modified 5 years, 10 months ago Viewed 2k times -2 Can any one explain the difference between SQL (Structured Query Language) and SOQL (Salesforce Object Query Language)? I need to convert dynamic SQL query into SOQL query using C# . __r represents a custom relationship. SOQL retrieves the data from the database using “ SELECT ” keyword. The ability to query five levels of parent-child relationships is limited to SOQL queries via the REST and SOAP query calls for standards and custom objects. EG A report can only report on (essentially) 4 objects in a parent child relationship, whereas with SOQL you could join queries and data together via maps/lists and create more complex relationships. null. That results in different ways you need to communicate with your Salesforce database. The Lightning Platform query optimizer works on automatically generated queries that handle reports, list views, and SOQL queries. If it's used in Apex code it's limited to the total governor limit for SOQL rows, which is currently 50,000. The query is: SELECT CronJobDetail. soql files. Using functions to operate on strings is also different between the SQL standard and T-SQL. Right-click the file name, select Open With, then SOQL Builder. You can use SOQL to query child-to-parent relationships, which are often many-to-one, and to query parent-to-child relationships, which are almost always one-to-many. SOQL and SOSL have different indexes. Because SOQL uses objects, instead of the tables and rows that are in standard SQL, SOQL query types are limited. Scalability. Salesforce のカスタム UI を作成している場合、Salesforce Object Query Language (SOQL) と Salesforce Object Search Language (SOSL) の API を使用して、組織の Salesforce データを検索できます。. UNION. It is a structured query programming language that manages the relational database management system. SOQL for loops iterate over all of the sObject records returned by a SOQL query. In layman's terms, SQL could be seen as a bank teller and MySQL could be. The SQL LIKE and NOT LIKE operators are used to find matches between a string and a given pattern. SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. name AS pet_name, owners. Because they allow a dynamic schema for unstructured data, there’s less need to pre-plan and pre-organize data, and it’s easier to make modifications. SOQL query :Salesforce. Doc: SOQL and SOSL Reference; Doc: SOQL and SOSL Queries; Trailhead: Get Started with SOQL Queries LIMIT. countryVS Code Extensions. No server-side overhead is needed to parse GraphQL, reducing runtime. Adrian Larson ♦. The NoSQL database is the newer one database that provides a mechanism for storage and. Gives you a table of all cities in MA and the number of addresses in each city. Simplify development and build automation with a command-line interface. SQL vs SOQL. Whether you use SOQL or SOSL depends on whether you know which objects or fields you want to search, plus other considerations. x. For example, the Who relationship field of a Task can be a Contact or a Lead. What is the difference between SOQL and SAQL? - Salesforce Developer Community Home » Discussion Forums » What is the difference between SOQL and. So, you can copy and paste the SOQL into your Apex code as-is. SQL is used for getting data from one or more tables. Name LIKE '%bla bla2%'. ] Use the FIELDS () keyword in the fieldList to select groups of fields without knowing. SQL is one of the most popular query languages of. Otherwise, any argument of type varbinary(max) or varchar(max): varchar(max), unless one of the parameters is an nvarchar of any length. Before we start writing and executing queries, you need some data in your Salesforce org that we can search for. Change the name of the table to Custom SQL Query as depicted below. HAVING: is used to check conditions after the aggregation takes place. Fetch the data from related objects: -. The name of a field for the specified object. The difference between SQL and T-SQL is that the latter has more features intended to help you in making query writing easier, quicker, and more efficient. Databases based on the relational model include MySQL, MS-SQL Server,. Some are SQL databases, some are NoSQL databases. So in your 2 examples: SELECT agentId, SUM (quantity) total_sales FROM sales s, houses h WHERE s. GraphQL is not SQL! Instead, GraphQL is data-agonistic, and GraphQL, being one of the possible and most popular way, uses SQL to fetch data. The Socrata APIs provide rich query functionality through a query language we call the “Socrata Query Language” or “SoQL”. In SQL, the AND & OR operators are used for filtering the data and getting precise results based on conditions. Tableau Desktop lets users edit a Custom SQL Query. SOQL クエリでは、 SELECT ステートメントで使用する WHERE 句の項目式に =、<、>、IN、LIKE などの比較演算子を含めることができます。. It is used along with the WHERE clause of the UPDATE, DELETE and SELECT statements, to filter the rows based on the given pattern. type = "condo" GROUP BY agentId ORDER BY total_sales; Step 1:. There is little consistency in database products. Despite SQL being adopted as a standard by the American National Standards Institute (ANSI), the codes require adjustments to be portable on different database systems. One of the biggest decisions is to determine the best platforms to use for storing and delivering the application data. FirstName, con. . WHERE. SOQL is syntactically similar to SQL (Structured Query Language). Example. We looked at 4 different types of join clauses. The SQL LIKE Operator. Por último, las NoSQL permiten un. = Operator : The = operator is used with Where Clause in SQL. The SQL IN Operator. While most developers are SQL-literate, there are small but important distinctions between SOQL and SQL. Last Name. SOQLには INSERT、UPDATE、DELETE ステートメントにあたるものが存在しない。なので以下はSELECTにフォーカスを当ててみていこうと思う。 joinが使えない. SELECT Id, Name, (SELECT Name From Contacts) FROM. SQL is a language used to query data from a general database. Difference Between SOQL and SQL. query ('SELECT Id, Name FROM. com's database query language, similar to SQL. Therefore, the actual maximum length of the IN clause is less than 4,000 characters (because the field name and the string ' IN ' contribute to the 4,000 characters. I used the following in my WHERE clause, and it works as a replacement that operates the same as LAST_N_DAYS is documented as expecting to work. The SQL LIKE operator is used to retrieve the data in a column of a table, based on a specified pattern. HAVING: is used to check conditions after the aggregation takes place. SQL (Structured Query Language) is a standard language for storing, manipulating and retrieving data in databases. In this article, Robert Sheldon explains how to choose between SQL and NoSQL databases. For Example Key differences. You'd think the optimizer would be smart enough to recognize the equivalence, but it's apparently not. These two operators can be combined to test for multiple conditions in a SELECT, INSERT, UPDATE, or DELETE statement. Prettier-SQL. owner_id = owners. g. g. 0 and later, SOQL queries can contain up to five levels of parent-to-child relationships. On the other hand, MySQL is a relational database management system that allows a user to store and retrieve data from the database. The issue you're running into appears solely to be an. This code: select City, CNT=Count (1) From Address Where State = 'MA' Group By City. The risks are much lower for SOQL injection than for SQL injection, but the attacks are nearly identical to traditional SQL. From that, you can create a new DateTime with the DateTime. if you follow a most desired coding. General : SOQL: SQL was also usually paired with the acronym RDBMS (relational database management system). In this blog post, we’ll explore how to use them in Apex, including best practices to prevent hitting governor limits. To create a dynamic SOQL query at run time, use the Database. The ability to query five levels of parent-child relationships is limited to SOQL queries via the REST and SOAP query calls for standards and custom objects. Click Query. Difference between SOQL and SQL query syntax. Nested square brackets indicate elements that are optional and can only be used if the parent optional element is present. リレーションクエリについて. SOQL クエリでは、 SELECT ステートメントで使用する WHERE 句の項目式に =、<、>、IN、LIKE などの比較演算子を含めることができます。. The FuseIT SFDC Explorer has an option to export SOQL query results as CSV. In SQL, you need to fill the field with a value anyway. SQL is used for accessing, updating and maintaining data in a database and MySQL is an RDBMS that allows users to keep the data that exists in a database organized. Differences Between SOQL and SQL Explained. 1. Print output. However, they are slower, less secure, more prone to errors, harder to debug and test, and cannot use some SOQL features. A WHERE with NOT negates the specified condition. For example, searching for 'Digital' in SOSL returns records whose field values are 'Digital' or 'The Digital Company', but SOQL returns only records with field values of 'Digital'. Click File > Save to. Query 2: SELECT Id FROM Account WHERE Name != ''. REST. results of selection where a single result, such as count, average, min, max, or sum, has been produced from multiple rows. Each course is interactive, and the exercises are based on real-world scenarios. As a result, NoSQL databases don't follow a rigid schema but instead. The SQL AND condition and OR condition can be combined to test for multiple conditions in a SELECT, INSERT, UPDATE, or DELETE statement. Obviously Cast (TextField as Integer) does NOT work. SOQL vs SOSL : SOQL: SOSL: Full Name: Salesforce Object Query Language: Salesforce Object Search Language: Used In: List Views, Reports, Apex (Global, Sidebar, Advanced) Search, Apex: Indexing Happens: Synchronously (Can have Custom Indexes or Standard Indexes) Happens Asynchronously. Performance on Time: (1172 row (s) affected) SQL Server Execution Times: CPU time = 0 ms, elapsed time = 39 ms. SQL (Structured Query Language) is typically used for working with data stored in relational databases—you might already be familiar with variants like MySQL and PostGreSQL. 次の表に、 fieldExpression. That said, the best use case of dbAmp isn't to replace your SOQL with SQL, but to use TSQL to do some advanced manipulation with your Salesforce. 4. When copying data from Salesforce, you can use either SOQL query or SQL query. The Schema Explorer is a tool for browsing the objects and fields in a Force. Furthermore, SQL can retrieve unrelated data while SOQL can only be used to query related information. In a grouped query, SQL returns a group for null values in a grouped query by default. SOSL Queries. SQLite is an Embeddable Relational Database Management System which is written in ANSI-C. This is a human concept. SQL and NoSQL are two different database technologies, each with its own set of strengths and weaknesses. Name = 'ZS_Lead' AND CreatedDate = Today]; Both the SOQL statements above do the same thing - Get a list of Lead records of a particular record type. houseId AND h. MySQL provides a large range of reporting tools to aid application validity, but NoSQL databases lack analytical and performance testing reporting tools. 比較演算子では、準結合と反結合を使用して複雑なクエリを作成することもできます。. You can use GROUP BY ROLLUP with aggregate functions, such as SUM () and COUNT ( fieldName). A numeric value. Select count () From ProcessInstance where. null. Try formatting your SQL code with a few pre-defined styles. Furthermore, SQL can retrieve unrelated data while SOQL can only be used to query related information. Long, complex SOQL statements, such as statements that contain. An add-in for SQL Server Management Studio and Visual Studio, SQL Prompt strips away the repetition of coding. g. Here’s. Follow. Key differences. Usually, query hints include NOLOCK, Optimize For and Recompile. Plus, the NOT IN query complained of a missing index.