Arithmatic operation in string

  • declare @abc nvarchar(50)='500+200-100'

    select @abc

    from this I get, 500+200-100

    But How to get 600 ??

  • Hi

    Here is one option:

    DECLARE

    @abc NVARCHAR(50)='500+200-100'

    ,@sql AS VARCHAR (50)

    SET @sql =

    'select' +' ' + @abc

    EXEC (@sql)

    Andy

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply