Welcome to Sign in | Help

Re: Substring

  •  11-06-2008, 4:02 PM

    Re: Substring

    O soluţie muncitorească:

    DECLARE @Sir nvarchar(50)
    DECLARE @i int, @Nr varchar(20)

    SET @Sir = 'RXC2333323232'
    SET @i = LEN(@Sir)
    SET @Nr = ''

    WHILE @i>0 BEGIN
        IF SUBSTRING(@Sir,@i,1) LIKE '[0-9]' BEGIN
            SET @Nr = SUBSTRING(@Sir,@i,1) + @Nr
        END
        SET @i = @i - 1
    END

    SELECT @Nr

    If-ul se poate înlocui şi cu: IF ISNUMERIC(SUBSTRING(@Sir,@i,1)) BEGIN ...

    Cătălin D.
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems