I am running a query on the SQL server. I need to get records where LoginName is starting with a given string and ending with integers. I am running the below query but it does not return any record. Let me know if this is not possible in SQL so I will handle in C# code.
SELECT * from TestTable where LoginName like 'Input[0-9]*%'
Expected values:
Input
Input1
Input123
Not Expected values:
Inputabc
abc
<empty string>
abcInput
'Input', followed by a digit, followed by an asterisk (*). None of your expect results have a'*'in them. Seems you actually just wantLIKE 'Input[0-9]%'.*means "match zero to unlimited times" in regex syntax. So not valid in TSQL patternLIKEwill see*as a literal. Which is exactly why there are no rows, as I said too.*would work but your suggestedInput[0-9]is not equivalent as that means "at least once"