Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find fields containing the TAB character in SQL Server

Tags:

In SQL Server, what is the best way to identify all rows in a table where a certain column contains the TAB character (CHAR(9))

Is it as simple as

SELECT * FROM MyTable WHERE Field1 LIKE '%' + CHAR(9) + '%'
like image 254
Mike Avatar asked Jul 13 '15 08:07

Mike


People also ask

How do I select a tab in SQL?

Use the SQL tab to create an SQL WHERE clause to handle selection criteria that are more complex than can be defined on the Selection Criteria tab. For example, to select the appropriate set of data for a table, you might need a combination of AND and OR logical operators.

How do I find the characters in a column in SQL?

LEN() function calculates the number of characters of an input string, excluding the trailing spaces. It is an expression that can be a constant, variable, or column of either character or binary data. Returns : It returns the number of characters of an input string, excluding the trailing spaces.

How do I find the junk characters in SQL?

In this article, we covered the important SQL string functions TRIM and LENGTH to learn how to remove junk characters in SQL. If you want to detect hidden or unwanted characters as part of an initial diagnosis, use LENGTH . Then, use TRIM to get rid of unwanted characters.

How do I find the field containing the tab character in SQL Server?

select * from MyTable where Field1 '%' || CHR(9) || '%'; Other solution can be: Select * from MyTable where instr(Field1, CHR(9)) <> 0; Cheers!


Video Answer


1 Answers

RTRIM CHAR columns. like this:

SELECT        *
FROM          MyTable 
WHERE        (RTRIM(Field1) LIKE '%' + CHAR(9) +  '%')
like image 119
Salah Akbari Avatar answered Sep 17 '22 14:09

Salah Akbari