Please Login to Continue

This Is Not A Drill ( by Beck Mc Dowell)

This Is Not A Drill ( by Beck Mc Dowell)

$10.00

White Barn (Whisky Butterscotch) Scented Candle

White Barn (Whisky Butterscotch) Scented Candle

$35.00

Coastal Breeze (Good Soap)

Coastal Breeze (Good Soap)

$5.00

SQL Query Like does not work with Spaces in a String

Question: How do you get the TSQL Like keyword to work with spaces in the String Value?

Answer: You will have to replace the Space or Spaces in your String or Value passed to the SQL Server. See the example of C# (C-Sharp) code below:

 public async Task<List<YourClassModel>> SearchByMyValue(string myAwesomeValue)
        {
            
            string cleanedAwesomeValue = myAwesomeValue.Replace(" ","%");
//Then you can pass the cleanedAwesomeValue to the Database
}

//Sql Store Procedure
You can now use "LIKE" to search for cleanedAwesomeValue passed in as Store Proc Arguments

- In some other cases, you can just trim the values you are sending to the database by using a Trim() function built-in C-Sharp.
For example, myValueString.Trim() this will almost if at all give you the same results.

SQL Like does not work with spaces in parameter Technology published

Was this page helpful?

Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful..



© 2020 - ErnesTech - Privacy