I want to search records by its BIGINT primary key (SQL Server identity), but a want to compare them as string, not as numbers. I need it to suggest data in GUI of application.
Is it possible to find record by this way, while primary key index will still be used? How?
Select should on '123' query select rows like:
123
123456
123654654
You can also use
LEFTfunction for that:See this Demo
As @Dems explained in this comment, you can not make use of an index on the original datatype when you cast it in
VARCHAR.