The Replace keyword is mainly used to Replace a character in a string with another character. Today we will introduce you to use it to check whether a specific string is contained. The sample code is as follows, if you are interested, refer to the Replace keyword in sqlserver. It is mainly used to Replace a character in the string with another character. Today, we need to reverse thinking,
The Replace keyword is mainly used to Replace a character in a string with another character. Today we will introduce you to use it to check whether a specific string is contained. The sample code is as follows, if you are interested, refer to the Replace keyword in SQL server. It is mainly used to Replace a character in the string with another character. Today, we need to reverse thinking,
The Replace keyword is mainly used to Replace a character in a string with another character. Today we will introduce you to use it to check whether a specific string is contained. The sample code is as follows, if you are interested, refer
In SQL server, the Replace keyword is mainly used to Replace a character in a string with another character. Today, we need to reverse thinking. It can also be used to query whether a specific string is contained, for example, given the following Dataset
We hope to obtain records containing the "aaa" character from this DataSet. Note that 2nd pieces of data do not contain "aaa", but contain "aaaa ". The expected "" result is as follows:
The traditional thinking is definitely to find out how to contain three a strings. Some people will use like, but this will also be found together with four a strings. Here we will think about replacing the "aaa" in the string with Replace. If it can be replaced, it will prove that the string contains this character. After replacement, it will certainly be different from the original string, therefore, the following SQL statement is released. The Code is as follows:
SELECT * FROM [master]. [dbo]. [Table_5]
Where replace (',' + strNum + ', aaa,', '') <> ',' + strNum + ','