Rename SQL Server 2005 Row Values - sql

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'.

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

I think you can do this with substring too, but I could not remember the correct syntax, so I think you should try this.
It updates the values based on the 3rd and 4th characters in your table, so it exchanges 10 to 9, if that's what you are after.
There are a lot of ways to achieve this, it's just one of them.
update
I have tested this locally and it works.
UPDATE
dbo.Deposito
SET
nomor = REPLACE(nomor,'.10.','.09.')
WHERE
substring(nomor,4,2) = '10'

Related

How to determine the column with multiple items of data has one specified value in BigQuery?

This is my table:
I want to change the TargetCondition column to 'TRUE' when the ICD9CODE column contains a particular range (like between 250 and 250.93).
Please help me do it. Thanks
This is the code here:
update demo.fea_02 set TargetCondition = TRUE where ICD9Code like between '%250%' and '%250.93%'
got the error:
Syntax error: Unexpected keyword BETWEEN at [6:17]
This answers the original version of the question.
You would use update:
update mytable
set targetcondition = 'TRUE'
where icd9code like '%value%';

ERROR: syntax error at or near | modify('replace value of | PostgresSql

I am trying to write a query for updating xml column value it may have or may not have an existing value. I have tried this query but it is giving me syntax error don't know why. I am not SQL expert i am just working with existing code.
Error
ERROR: syntax error at or near "("
LINE 4: SET user_prop.modify('replace value of ("//PREF/NOTIFICATION...
^
SQL state: 42601
Character: 199
Query
UPDATE user
SET user_prop.modify('replace value of ("//PREF/NOTIFICATIONS/#ASK_YOUR_INSTR") with ("TRUE")') where username='1038125#';
XML Value
<PROP>
<ACL DENY="CREATECOURES"></ACL>
<PREF>
<NOTIFICATIONS ASK_YOUR_INSTR="FALSE" />
</PREF>
</PROP>
The SET part of an UPDATE needs an assignment, e.g.
update foo
set bar = bar + 1
where id = 1;
You haven't told us what your function modify() does, but if it returns the modified XML value, then I guess you are looking for:
UPDATE user
SET the_column = user_prop.modify('....')
where username='1038125#';
I guess this is the answer
UPDATE HR_XML
SET Salaries.modify('replace value of
(/Salaries/Marketing/Employee[#ID=("2")]/Salary/text())[1] with ("60000")')
can you try to remove the quotes from the //PREF/NOTIFICATIONS/#ASK_YOUR_INSTR

SQL UPDATE - INNER JOIN QUERY

I am trying to do an update in 2 tables, but i have this error:
Error SQL: ORA-00933: "SQL command not properly ended".
Could you help me please? The query is:
UPDATE a
SET a.ACTORID_ = SUBSTR(a.ACTORID_, 2, LENGTH(a.ACTORID_)),
b.TASKACTORID_ = SUBSTR(b.TASKACTORID_, 2, LENGTH(b.TASKACTORID_))
FROM jbpm_taskinstance AS a
INNER JOIN jbpm_log AS b
ON b.TASKACTORID_ = a.ACTORID_
WHERE a.ACTORID_ = b.TASKACTORID_
AND b.TASKINSTANCE_ IN (
SELECT ID_
FROM jbpm_taskinstance
WHERE a.PROCINST_ =b.PROCINST_)
AND b.TASKACTORID_ = a.ACTORID_;
Welcome to the world of strange and misleading Oracle error messages!
With experience, you can spot the error by sight, as #a_horse_with_no_name has done.
If you don't see the error immediately, I'd recommend to make the query simpler step by step until the error disappears. In your case, I would remove the AND b.taskinstance_ IN () subquery and check if the same error comes up. Then I'd remove the SUBSTR with a simple constant, like SET a.ACTORID_ = 'a'. Then I'd remove the JOIN, updating only table A. This will run ok, so you need to read up Oracle's documentation on UPDATE.

Update date within a table, Postgresql

So I'm having trouble understanding on how to change the date on an update in postgres. What I have currently, that is giving a syntax error is
UPDATE works_locations SET (wrl_startdate = '2014-09-07', wrl_enddate = '2015-02-06')
with a few statements determining which field I should specifically change. However, postgres is giving me an error. How do I successfully change the date in postgres, even if the start date is around two years prior to this entry?
I don't have Postgres installed so I can't test this but try removing the parenthesis on your SET clause so that it looks like this:
UPDATE works_locations SET wrl_startdate = '2014-09-07', wrl_enddate = '2015-02-06'

Update Field Geometry Polygon PostGIS PostgreSQL

I am having some trouble trying to update a field.
I created a column as text and stored many rows with (lon,lat). Now I have created one more field as Geometry(Polygon) and I am trying to update it unsuccessfully.
The data is stored like this:
POLYGON ((-16.6318775869111 -52.5925428149806, -16.6346393504709 -52.572542814981
, -16.629462102066 -52.5525428149806, -16.6255191065928 -52.5455420519144
, -16.6055191065928 -52.5488828022871, -16.6021791014778 -52.552542814981
, -16.6108484688169 -52.5925428149806, -16.6255191065928 -52.599495926874
, -16.6318775869111 -52.5925428149806))
I am trying this command
UPDATE field_as_text
SET field_as_geomtry = SELECT ST_GeomFromText(SELECT field_as_text);
I am getting this error message
ERROR: syntax error at or near "select"
LINE 1: ... set field_as_geomtry = select (ST...
Could anyone enlighten me?
You need to start by reading the manual about the SQL UPDATE command.
Should look something like this:
UPDATE table_name
SET field_as_geomtry = ST_GeomFromText(field_as_text);