tsql - Strip off any characters from a string in SQL Server -



tsql - Strip off any characters from a string in SQL Server -

i'm trying write stored procedures give next value on row.

in case, i'm sending reference number , stored procedure returns next ref number using min , >. ref number in table includes characters 123gf, 256er, 25gd gives me error when converting varchar int.

how strip off non-numerical number before comparing value passing value?

this current procedure code:

create procedure [dbo].nextprevious @refid integer, @next bit begin set nocount on; declare @lreturn integer if(@next = 1) select ref table ref =( select min(ref) table ref > @refid) else select ref table ref =( select max(ref) [ref ref < @refid) select @lreturn = @@rowcount homecoming @lreturn end go

if using sqlserver, below

other solution using replace function:

select replace(ref,'a','') table --to cutting off 1 char select replace(replace(ref,'a',''),'b','') table --to cutting off , b char

likewise chars

sql-server tsql stored-procedures

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -