Home

Crin dex

CHARINDEX performs comparisons based on the input collation. To perform a comparison in a specified collation, use COLLATE to apply an explicit collation to the input. The starting position returned is 1-based, not 0-based. 0x0000 ( char (0)) is an undefined character in Windows collations and cannot be included in CHARINDEX The CHARINDEX () function searches for a substring in a string, and returns the position. If the substring is not found, this function returns 0. Note: This function performs a case-insensitive search CHARINDEX is another simple function that accepts two arguments. The first argument is the character you are searching for; the second is the string. It will return the first index position that the character passed into the first argument is within the string. Now let's use our CHARINDEX function to find the position of the space in this string The CHARINDEX function returns an integer corresponding to the position of the substring (one-based, not zero-based). The position is based on the number of characters, not bytes, so that multi-byte characters are counted as single characters Learn about the Instring and CharIndex functions in the SQL Language. The Microsoft SQL Server CharIndex or Instring is used to find a character within a va..

CHARINDEX¶ Searches for the first occurrence of the first argument in the second argument and, if successful, returns the position (1-based) of the first argument in the second argument. Aliases. POSITION. Note that the CHARINDEX function does not support one of the syntax variations that POSITION supports This video explains about LENGTH, SUBSTRING and CHARINDEX method in SQL.#SQL-programmin Best Dishwasher detergents. Best Washing machines. Best Laundry detergents. Best Vacuum cleaners. Best Steam irons. Best Paper towels. Best Carpet cleaners. Best Clothes dryers. Best Boilers

A. Air Conditioners Portable Air Conditioners Window Air Conditioners. Air Filters Furnace Filters, Air Conditioner Filters & Air Filters. Air Fryers. Air Mattresses. Air Purifiers Room Air. i.e I would use CHARINDEX or PATINDEX if using SQL Server. I looked at using the Select-String cmdlet but it doesn't seem to do what I need it to do. Ultimately I'm looking to find a _ character in a file name and strip off everything to the following . . Example file name 237801_201011221155.xm CHARINDEX returns the INTEGER data type. Description. CHARINDEX searches a string for a substring. If a match is found, it returns the starting position of the first matching substring, counting from 1. If the substring cannot be found, CHARINDEX returns 0. The empty string is a string value It takes following parameters in SQL CHARINDEX function. expression_to_find: In this parameter, we specify a character or string that we want to search in another string ; expression_to_search: We can specify a string or sentence in which we want to search expression_to_find start_location: It is an optional parameter.We can specify an integer value in this parameter to specify start location

Returns Int32. The zero-based index position of value if that character is found, or -1 if it is not.. Examples. The following example demonstrates how you can search a String for a character using the IndexOf method.. using namespace System; void main() { // Create a Unicode String with 5 Greek Alpha characters CHARINDEX function The CHARINDEX function searches a character string for the first occurrence of a target substring, where the search begins at a specified or default character position within the source string.; INSTR function The INSTR function searches a character string for a specified substring, and returns the character position in that string where an occurrence of that a substring. E) Using CHARINDEX () function to searching from a specific position. This example uses the start_location parameter to start the search for 'is' at the fifth and tenth character of the string 'This is a my sister': SELECT CHARINDEX ( 'is', 'This is a my sister', 5) start_at_fifth, CHARINDEX ( 'is', 'This is a my sister', 10) start_at_tenth; In. SELECT CHARINDEX ('OM', 'Customer') AS MatchPosition; . Edit the SQL Statement, and click Run SQL to see the result

CHARINDEX (Transact-SQL) - SQL Server Microsoft Doc

  1. The CHARINDEX function searches a character string for the first occurrence of a target substring, where the search begins at a specified or default character position within the source string. Must be an expression, constant, column, or host variable of a built-in character type, or a type that can be converted to a character type
  2. CHARINDEX() function is used to perform case sensitive and case insensitive searches based on the collation specified in the query. Following is the syntax of the CHARDINDEX() function. CHARINDEX(substring, input_string [, start_location]) CHARINDEX() accepts three arguments
  3. In this article, we will explore SUBSTRING, PATINDEX and CHARINDEX string functions for SQL queries. Introduction. While working with the string data, we perform various calculations, analytics, search, replace strings using SQL queries
  4. Description. CHARINDEX searches a string for a substring. If a match is found, it returns the starting position of the first matching substring, counting from 1. If the substring cannot be found, CHARINDEX returns 0. The empty string is a string value
  5. 1. You should handle rows which don't have '/'. If you consider the values like before '/'. SELECT TOP 1 * FROM arquivo A, tabela_geral B (NOLOCK), campo_concatenado C (NOLOCK) WHERE A.primeira_parte = COALESCE (SUBSTRING (C.concatenado, 1, NULLIF (CHARINDEX ('/', C.concatenado), 0) -1), C.concatenado) AND B.status = 0 AND B.campo = '13' AND B.

SQL Server CHARINDEX() Function - W3School

As soon as I replied here, a new possibility dawned on me. Here's code that works: CASE WHEN CHARINDEX(CHAR(63), email_tracking.url) IS NOT NULL THEN LEFT(email_tracking.url,(CHARINDEX(CHAR(63),email_tracking.url)-1)) ELSE email_tracking.url ENDCHAR(63) sends the ASCII code for ? which gets around SSRS looking for a parameter and doesn't require any escape characters for SQL You can find a specific character, such as a letter, a group of letters, or special characters, by using the index function. For example, suppose that you have a data file with names and other information and you want to identify only those records for people with Harvey in their name. You could use the index function as shown below In SQL Server, you can use either the CHARINDEX() function or the PATINDEX() function to find a string within a string. These are Transact-SQL string functions, and they're also available on Azure databases.. On the surface, these functions appear to do exactly the same thing, and in many cases, you could use whichever you prefer to use

Hello all, I figure out how to get two numbers out of an string select dba_id, RTRIM(substring(SUBSTRING(dba_id, 10, 15),1,charindex('-',SUBSTRING(dba_id,10, 15))-1. CHARINDEX function Examples. Find the first occurrence of 'uzzy' in 'fuzzy wuzzy': Same example as before, but starting at position 5 so the second occurrence, rather than the first, is found: Search for various characters, including unicode characters, in strings: Search for bytes in a binary value. Note that because the values below. Charindex TSQL Tutorial. Search an expression in an string expression and returns its starting position if found. Charindex function syntax. charindex ( search_expression ,string_expression [ , start_location ] The CHARINDEX has a third optional argument as well. This is the start location in the string which is an int type. If no match is found in the given string, the CHARINDEX returns 0. See the section below for seeing the examples and results as using the CHARINDEX SQL Server function. The example of using CHARINDEX functio CharIndex Reverse - find occurrence starting from end of string in TSQL. Joel Lipman. Transact-SQL. 28 January 2013. Hits: 34933. What? This is a quick note on finding the last occurrence of a string in a longer string. This has to be in Transact SQL for a SQL Server instance only and not filtered by other code. Why

T-SQL: RIGHT, LEFT, SUBSTRING and CHARINDEX Functions

Tipo de retorno. La función CHARINDEX devuelve un valor entero correspondiente a la posición de la subcadena (basado en 1, no basado en cero). La posición se basa en la cantidad de caracteres, no bytes, por lo que los caracteres multibyte se cuentan como caracteres simples CHARINDEX equivalent in DB2. Ask Question Asked 2 years ago. Active 2 years ago. Viewed 4k times 2 I am trying to select the domain from the column where I have email addresses. For example, I have a table email_table and a column email with email addresses as below. johndoe@gmail.com jhefid@yahoo.com ipw@gmx.com.

UNKNOWN SOLDIER #9

Cr index. A Process Capability Index. A measure of the percentage of the tolerance actually used by the process. Smaller numbers are best. where Cp is the Process Capability Index. Learn more about the SPC principles and tools for process improvement in Statistical Process Control Demystified (2011, McGraw-Hill) by Paul Keller, in his online. C. R. Laurence is the world leader, wholesale distributor to the Glazing, Industrial, Construction, Architectural, Hardware and Automotive Industries, supplying railing, windscreen, standoffs, and other supplies to major industries and manufacturers How to get a substring between two characters with T-SQL. This is a very common activity in the data world, i.e. there's some data in a text string you need and the rest of the data in the string is just in your way. Some use cases might be you have a reference in a filename you need to extract, or you may need a snippet of data to create a.

CHARINDEX function - Amazon Redshif

  1. SQL CHARINDEX Function. The SQL CHARINDEX function is a String Function that finds the index position of a given expression from existing records. The SQL CHARINDEX Function index position will start from 1, Not 0. SQL CHARINDEX Function Syntax. The syntax of the SQL CHARINDEX Function is. SELECT CHARINDEX (ExpressionToFind, ExpressionToSearch.
  2. The CHARINDEX function in SQL Server lets you search for one string inside another string, from a specific location. It returns the position of the string if it is found, or 0 if it is not found. It's comparable to INSTR in other databases and applications. Only the position of the first occurrence is shown
  3. The CHARINDEX and PATINDEX functions are used to search a character string for a character or set of characters. If the character string being searched contains the characters being searched for, then these functions return a non-zero integer value. This integer value is the starting location of where the character string being searched for is.
  4. CHARINDEX - a string function used to find the start index of the first occurrence of input string inside another target string. It returns the location, index number of the first occurrence. CHARINDEX provides a similar output as IndexOf function in C#. The function accepts three parameters whereas the third parameter is optional

1. SELECT RIGHT(FileName, CHARINDEX ('\', REVERSE (FileName)) - 1) FROM @FileNames. For those of you that don't just copy and paste code from the internet without understanding how it works, let's break this down. We REVERSE the FileName to flip the string and make the last whack the first. Then we use CHARINDEX to find the first whack (of. CHARINDEX¶ Sucht nach dem ersten Auftreten des ersten Arguments im zweiten Argument und gibt bei Erfolg die Position (1-basiert) des ersten Arguments im zweiten Argument zurück. Aliasse. POSITION. Beachten Sie, dass die Funktion CHARINDEX keine der Syntaxvarianten unterstützt, die von POSITION unterstützt werden U.S. Aluminum is a manufacturer and supplier of Doors, Entrances, Storefronts, Curtain Walls, Sun Control Systems, Window Wall Systems, Hurricane Resistant Building Fronts, Blast Mitigation Systems, and Custom Extrusions INSTR . Syntax. Description of the illustration instr.gif. Purpose. The INSTR functions search string for substring.The function returns an integer indicating the position of the character in string that is the first character of this occurrence. INSTR calculates strings using characters as defined by the input character set.INSTRB uses bytes instead of characters Well i was given the task to get the email id's of the user which was stored in one of our oracle db table. But the problem was that we wanted that part of emailid which appears before '@' . Well coming from SQL Server background i thought it could be acheived using CharIndex and Lef

Note that when defining the second character, the CHARINDEX function uses the starting position, which is the position following the first letter of a character - CHARINDEX('a', name)+1. The correctness of the result - 2 and 10 - is easy to check I want the equivalent of this for ints. --Valid SQL DECLARE @users AS nvarchar(50) SET @users = 'Joe ,Bob,Fred,Tim' --1,2,8,23 select * FROM Person AS p WHERE CHARINDEX(p.sFullName,@users) > 0. Difference between CHARINDEX and PATINDEX CHARINDEX and PATINDEX both functions are used to find the position of a specific character(s) in sql server. Then these should be a question that what the difference between these. Here are differences.The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify SELECT CHARINDEX ('mer', 'Customer', 3) AS MatchPosition; . Edit the SQL Statement, and click Run SQL to see the result

Traiter le papillomavirus chez lhomme, Mult mai mult decât

SQL CharIndex - Instring - SQL Training Online - Quick

charindex. 1 post Difference between Clustered and Non-clustered index ? Editor; July 18, 2021; Answer : Cluster index: Clustered index will be created View Answer Search for: Search. Recent Posts. Which is the largest ship in Indian navy A quick tip for the beginners. Most of you would be familiar with substring searches in SQL. Today, we will see how to replicate the same scenario in MDX. 1) Suppose we have to find all the employ CHARINDEX is used to get starting position of the specified expression in a string. Syntax of CHARINDEX Function : CHARINDEX (expression1 ,expression2 [ ,start_location ] ) expression1 is a sequence of characters to be found from expression2. It is of short character data type

CHARINDEX function searches for one character expression inside a second character expression, returning the starting position of the first expression if found. Let's see the function syntax: In this function there are three parameters. Two are mandatory and third one is optional. Parameter expressionToFind is a character expression. SQL CHARINDEX Function Example. By Ankit Lathiya Last updated Dec 24, 2019. SQL CHARINDEX is an inbuilt function that is used for returning the location of a substring of a given string. SQL CHARINDEX function is not case-sensitive. SQL CHARINDEX function searches for a substring inside a string starting from a specified location However the seceond column that says lastname does the trick. I used Charindex to determine the space in the string starting from the right by reversing the string with my names in it. Then i took the RIGHT function to actually get the number of characters from the right determined by charindex in the reversed string of names

CHARINDEX — Snowflake Documentatio

  1. The SUBSTRING(@lineString,1,CHARINDEX('@',@lineString)-11) is the way to go. To get the birthdate, we apply the same logic. Get the position of the @ character and move 10 characters backward to get the birthdate start value. 10 is a fixed length. SUBSTRING(@lineString,CHARINDEX('@',@lineString)-10,10) is how to get the birthdate
  2. Reverse the string, use CHARINDEX to get the first delimiter (which is really the last), SUBSTRING that, then re-REVERSE it! Reply. Erik Darling says: October 20, 2020 at 11:23 am. Ooh yeah, I've seen that for default trace location parsing, too. Sometimes even I can't wrap my head around that, hahaha
  3. This SQL Server tutorial explains how to use the CHARINDEX function in SQL Server (Transact-SQL) with syntax and examples. In SQL Server (Transact-SQL), the CHARINDEX functions returns the location of a substring in a string. The search is NOT case-sensitive
  4. The SQL CHARINDEX() | LOCATE() | INSTR() is a function and returns the index position of the first occurrence of substring of a given input string or text.. The SQL CHARINDEX() use to find the numeric starting position of a search string inside another string.. The SQL CHARINDEX() function returns 0 if given substring does not exist in the input string..
  5. SUBSTRING([RH_ACCOUNT],0,CHARINDEX(',',[RH_ACCOUNT])) I know that the values within the column, with an occasional NULL for some reason. That should work, but you'll need to subtract 1 from the charindex or it will include the comma in your output

11. How to use LENGTH, SUBSTRING and CHARINDEX in SQL ..

JOKERS ASYLUM THE PENGUIN #1

Index Page from ConsumerReports

forcharIndex 5 charIndex 1 charIndex iffdigits charIndex from TECHNOLOGY 1 at Lincoln Technical Institute, Lincol t=> SELECT line, CHARINDEX ('the', line) FROM jabberwocky line | charindex-----+-----'Twas brillig, and the slithy toves | 20 Did gyre and gimble in the wabe: | 30 All mimsy were the borogoves, | 16 And the mome raths outgrab The CharIndex and PatIndex functions both categorized under the string function in SQL SERVER with little bit of difference. So, this blog explore the difference between CharIndex and PatIndex function in SQL SERVER Using SUBSTRING () and CHARINDEX () In this lesson, you learned how to split one column into more columns. The clients_split table has one column, city_state, that stores the cities where the clients live and the state of the city. The values of this column have this appearance: 'Chicago, Illinois'. You need to split this column into two new. The CHARINDEX function is used in Microsoft SQL Server to retrieve the position of a substring in the specified string. Oracle uses with this purpose the INSTR function. These functions have a similar syntax and differ in the parameter order. SQLWays converts the Microsoft SQL Server function CHARINDEX to the Oracle function INSTR

A-Z from ConsumerReports

  1. CHARINDEX provides an easy way to search for the first occurrence of a string in another string. By reversing the order of the string it can also provide a straightforward way of finding the last occurrence of a string. This can be used in conjunction with the RIGHT function to extract the part of a string that is after the last occurrence of a given delimite
  2. Functionality of CHARINDEX() In XIr2 814 Views I have a field that may or may not contain a specific character (such as /) - in those records that do contain a /, I want to return all of the characters to the LEFT of the /, not including the slash
  3. Filings submitted via the online portal will be processed and posted promptly to the bureau's online registry. If you have any questions, please email Charities.Bureau@ag.ny.gov. Submit your annual filing online now. Printable forms for manual filing: CHAR 500 (2020) Annual Filing for Charitable Organizations - 2020
  4. Within all medical fields, a uniform response is an essential parameter. A uniform exposure should result in a uniform response of the computed radiography imaging system - optimizing the quality of CR radiographs should be the goal of each and every radiology department. Uniformity testing in computed radiography serves two purposes: evaluating the global uniformity index and detection of.

powershell - Find character position and update file name

  1. Online Course Support. Due to the COVID-19 pandemic, College of the Redwoods will be suspending most face-to-face classes and providing remote instruction for the Spring 2021 Semester
  2. Teradata - POSITION Function - Get Position of Substring in String. POSITION function returns the position (integer number) of a substring in a string. Quick Example : Find position of word Jose in string San Jose : SELECT POSITION ('Jose' IN 'San Jose') ; -- Result: 5
  3. g the calculation until the final result set has been deter
  4. Actually, you can apply the VB macro to find nth occurrence or position of a specific character in one cell easily. Step 1: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window. Step 2: Click Insert > Module, and paste the following macro in the Module Window

CHARINDEX - InterSystems SQL Reference - InterSystems IRIS

The Basics. The INDEX function searches source, from left to right, for the first occurrence of the string specified in excerpt, and returns the position in source of the string's first character. If the string is not found in source, INDEX returns a value of 0.If there are multiple occurrences of the string, INDEX returns only the position of the first occurrence Looking for Cr fonts? Download it free at FontRiver.com! - page 14 Now, lets have a look at CHARINDEX SQL function: CHARINDEX (expressionToFind ,expressionToSearch [ ,start_location ] ) expressionToFind - Is a character expression that contains the sequence to be found. ExpressionToFind is limited to 8000 characters. ExpressionToSearch - Is a character expression to be searched The CHARINDEX() function returns the location of a search string within another string. For Example: This code will return 11, which equates to the position of 'sentance' within the string 'This is a sentance' Since there is no space in the value of the @FullName, the CHARINDEX string function will return a value of 0 since it was not able to find the search string (in this case, the space) from the string expression passed. Subtracting 1 from it yields a value of -1, which is not allowed as the length in the LEFT function

CHARINDEX(search_string, string_to_be_searched [,start_location]) Here is a working example: SELECT CHARINDEX('x', 'Wheres the x in this?', 1) AS X_Position. Running the above code returns: 12. A variation on the CharIndex function Now what happens if you have the following string: 4324789432,781224392,7890975432,18947329473129,78437843,8372729. What you can do to get around these overzealous validations is use the CHAR () funtion to have the SQL fill in that char without explicitly writing it. E.g. ( = CHAR (40). So for instance: SELECT SubscriberKey, LEFT (columnName, CHARINDEX (CHAR (40),columnName)-1) as columnName FROM [test_charIndex] Should do the trick

CHARINDEX(string-expression-1, string-expression-2) Parameters string-expression-1 The string for which you are searching. string-expression-2 The string to be searched. Remarks The first character of string-expression-1 is identified as 1. If the string being searched contains more than one instance of the other string, then the CHARINDEX. SQL Server REVERSE String Function with Examples 2008, R2, 2012, 2014. The SQL Server REVERSE string function can be quite useful if you need to return a string or sequence in reverse order. It can also be quite powerful when used in combination of other SQL keywords (CHARINDEX, RIGHT). We'll start by looking at some of the simple uses -charindex(' ',name) is the position in the string of the first space character -datalength(name)-charindex(' ',name) is the number of characters after the first space -substring(name,1,charindex(' ',name)-1) -says parse the field from the first char to the char BEFORE (n-1) the spac

SQL CHARINDEX - SQL Shac

Oh, right, parsing file & directory names. As a DBA, there seems to be a constant trickle of automation where I need to parse a file name out of a full path. PowerShell does a much better job at this than T-SQL. Go ahead and write a comment below that I should use PowerShell (or Python, or .NET, or some other language) to parse file names CHARINDEX() This function is used to search for a specific word or a substring in an overall string and returns its starting position of match. In case no word is found, then it will return 0 (zero). Let us understand this with examples. Syntax. CHARINDEX ( SearchString,WholeString[ , startlocation ] The charIndex read-only property of the SpeechSynthesisUtterance interface returns the index position of the character in the SpeechSynthesisUtterance.text that was being spoken when the event was triggered

String.IndexOf Method (System) Microsoft Doc

SQL SERVER - Search Records with Single Quotes - Part 2. Pinal Dave is an SQL Server Performance Tuning Expert and independent consultant with over 17 years of hands-on experience. He holds a Masters of Science degree and numerous database certifications. Pinal has authored 13 SQL Server database books and 40 Pluralsight courses In our example, we need to find after 56. So the code should looks like this: select CHARINDEX (' ', 'Posted/edited: 56 days ago', CHARINDEX ('56', 'Posted/edited: 56 days ago', 0)); OUTPUT: 18. StepUp. 2. You are already getting position of the second space (' ') in your query => 15. To clarify for example, you can use it to extract content. The CHARINDEX() Function. The T-SQL CHARINDEX() function is similar to PATINDEX(). However, there are some differences between the two. In particular, the PATINDEX() accepts wildcard characters, but not a starting position. CHARINDEX() on the other hand accepts a starting position, but not wildcard characters In the CHARINDEX function, if the space is not found in the full name, it returns a value of 0. Then subtracting 1 from this gives a value of -1. Using the NULLIF function, we are changing the length parameter passed to the SUBSTRING function to NULL if the value returned by the CHARINDEX minus 1 is -1. In the SUBSTRING function if the length.

LEN(), SUBSTRING(), CHARINDEX(), LEFT(), RIGHT() etc. Then he asked me, Can you give me one example of where you have used these functions in your experience? The following is one simple real time example, where we can use LEN(), CHARINDEX() and SUBSTRING() functions. Let us assume we have table as shown below Hi, I wanted to add an additional column to a view with the following calculation CASE WHEN CHARINDEX('_',[Rec Name]) >=1 then left([Rec Name],CHARINDEX('_',[Rec Name])-1) ELSE 'NA' END Recnew CHARINDEX is not available in TDV. How can I accomplish? Thanks, JohnHi, I wanted to add an additional column to a view with the following calculation CASE WHEN CHARINDEX('_',[Rec Name] The CHARINDEX function in a SELECT statement presents the syntax and lets you examine how it works for finding the position of the first space in the name field. The first character in the name field, J, has position 1 so that the location of the blank space is 7 The tutorial shows how to use the Substring functions in Excel to extract text from a cell, get a substring before or after a specified character, find cells containing part of a string, and more. Before we start discussing different techniques to manipulate substrings in Excel, let's just take a moment to define the term so that we can begin on the same page CHARINDEX in action! LEN. The LEN function returns the number of characters in a string. In the following example you can see that the length of SQL Server is 10. Example of the LEN function. Length is rarely used on its own. It is used mainly in conjunction with other functions, such as LEFT and RIGHT. Functions used to Transform String

Substring functions - IB

Here is the quick script I wrote down using PATINDEX. The function PATINDEX exists for quite a long time in SQL Server but I hardly see it being used. Well, at least I use it and I am comfortable using it. Here is a simple script which I use when I have to identify first non-numeric character. 1 pointer = CHARINDEX(@Delim + value + @Delim, @Delim + @List + @Delim) FROM STRING_SPLIT(@List, @Delim) GROUP BY value) AS x; Results: Here is another example to rollup columns for indexes.-- Purpose: This query will list all indexes in the database and show index columns and included columns using STRING_AGG (SQL 2017 and later)

Name POSITION The POSITION function returns an integer that indicates the starting position of a string within the search string. ANSI SQL Standard Syntax POSITION( string1 IN string2 ) The - Selection from SQL in a Nutshell, 3rd Edition [Book Next, we used the CHARINDEX function to find the @ symbol, and then added 1, so that the starting point will be after the @ symbol. Then, we used the LEN function to specify the end value. 2. Count the number of extracted Domain From Email in SQL Server : Approach 1 : SQL Query to Count Number of Records for Extract Domain name From Email Charindex() is returning the location of the comma. So using the example of Bloggs,Joe, the comma is in position 7. So Right() will return the last 7 characters which in this case is ggs,Joe. You need to subtract the position of the comma (7) from the length of the string (10) which gives you the right length of the string to return:. CHARINDEX ( expression1 ,expression2 [ , start_location ] ) Arguments. expression1. Is an expression that contains the sequence of characters to be found. expression1 is an expression of the character string data type category. expression2 [u0].[Name] LIKE @__name_0 + '%' AND (CHARINDEX(@__name_0, [u0].[Name]) = 1)) OR (@__name_0 = N'')) The idea is with LIKE condition to allow query optimizer to use the index, and then do the slow filtering with the second condition like before (it's all about handling correctly (similar to C#) the wildcard characters inside the search string as.