Search code examples
sqlsql-serversql-server-2014

SQL Change Value + 10000


I Need help to change several values into a column in SQL, making an addition +10000 on the value actually inside the column. For example, the value in tPatSSlida of the first Name, in this case CLINIC DENT have to change from 0000000001 to 0000010001


Solution

  • Try this

    UPDATE TPatientRaw 
    SET tPatSSlidaID = RIGHT('0000000000' + CAST(CAST(tPatSSlida AS int) + 10000 AS VARCHAR), 10)
    WHERE tPatSName = 'CLINIC DENT'
    

    simple test