Search code examples
sqlsql-serverrenamesql-server-2005-express

Rename SQL Server 2005 Row Values


I want to rename several values on my table.

I just want to rename multi rows in a column of a table in my database :

SJ.10.06.000001
SJ.10.06.000002
SJ.10.06.000003
SA.10.06.000001
SB.10.06.000002

etc into this value :

SJ.09.06.000001
SJ.09.06.000002
SJ.09.06.000003
SA.09.06.000001
SB.09.06.000002

My SQL :

Update dbo.Deposito 
set nomor sj.09... 
where no rekening sj.10...

and I've got this :

Update dbo.Deposito 
set nomor sj.09... 
where no rekening sj.10...

Error

[Err] 42000 - [SQL Server]Incorrect syntax near 'sj'.


Solution

  • try this....

    UPDATE dbo.Deposito 
     SET nomor =  REPLACE(nomor, '.10.', '.09.')
    WHERE SUBSTRING(nomor, 4, 2) = '10'