SQL convert Varchar to int stored prod


I have the following stored prod

GetSearch @JoinClause = N'', @WhereClause = N' (A.S LIKE ''2A%'') And (A.W Like ''%2000%'') And (A.L LIKE ''100'') ', @LD = 1

What i want to do is convert the  A.S LIKE ''2A%' and A.L LIKE ''100'' to  A.S >=''2A%'  and
A.L <=''100' .

But i need a convert to int in there somewhere as those fields are declared as VARCHARS and i dont want to change the declaration. So how do i do this please help



Who is Participating?
RiteshShahConnect With a Mentor Commented:
you can't convert "2A" to INT at any cost, more over you can't use wild card "%" with ">=".

as long as A.L concern you can do something like

A.L<= cast("100" as INT)

make sure only numeric value get passed there, NO ALPHABETIC value. if there is possibility of NULL than you case use

A.L<= cast(isnull("100",0) as INT)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.