I need Records between two strings passing through Parameters. @startString and @end String.
Between Query is possible between in these two strings?
10-00-000-000000 and 12-02-023-000000
I need Records between two strings passing through Parameters. @startString and @end String.
Between Query is possible between in these two strings?
10-00-000-000000 and 12-02-023-000000
Replace your column with Column1
SELECT * FROM TABLE1 WHERE CONVERT(BIGINT,REPLACE(@Column1,'-','')) BETWEEN
CONVERT(BIGINT,REPLACE(@startString,'-','')) AND
CONVERT(BIGINT,REPLACE(@endString,'-',''))
If your strings 10-00-000-000000
and 12-02-023-000000
are always in the same format xx-xx-xxx-xxxxxx
(2-2-3-6 numbers) you can compare them on alphanumeric base just using
WHERE YourColumn BETWEEN @startString AND @endString
I'm assuming, that YourColumn
is a string column with exactly the same format.
But if the numbering/format might differ you first have to specify What is the implicit sort order? Is 10-90-...
higher or lower than 10-100-...
?