msql replace links in database - sql

I have again problem with multiple rows in db. They are about 40k rows which need to be replaced to new link. What i want is to add some text after whole link which is saved into db. My example:
UPDATE Stores SET MapView = REPLACE(MapView,'&a=b','http://link.com/xy');
But this doesnt work affcourse, it replaces whole link with a, what i want is to get like that: http://link.com/xy&a=b
Any chance to do it?

Is this?
UPDATE Stores SET MapView = concat(MapView,'&a=b');

Related

how to change specific text in a column but keep the rest

I am using SQL in navicat. I would like to change the UID below to id and keep the rest of the text in each column. The numbers after the = are different in each record.
EXAMPLE:
3PYTW2X?UID=5493139 and I want it changed to 3PYTW2X?id=5493139
3PYTW2X?UID=2986225 and I want it changed to 3PYTW2X?id=2986225
I have about 200k records that need to be updated.
Thank you in advance!
Use a replace function:
REPLACE(FieldName,'UID','ID')

Update custom fields in an VBAP append structure via VA02

I have the following requirement. I need to save some parameters in the table VBAP. I've created additional fields in an append structure for that. Now, when a sales document is being saved, the parameters have to be updated as well.
For this I've been using USEREXIT_SAVE_DOCUMENT in the program SAPMV45A. There I loop over the table XVBAP where I set the fields.
This works as expected for existing positions. When a new position is being added the fields won't be updated and are empty.
What am I missing here? Do I have to use a different user exit for new positions?
Thanks in advance.
you can use "USEREXIT_MOVE_FIELD_TO_VBAP" in MV45AFZZ

How to update a sql record text, by replacing a string for various text?

I have to update a table record where I am replacing some old email ids with a new id.
I am at the moment doing replace like
replace(replace(replace( column, 'abd#xyz.com', 'new#email.com),'old#re.com', 'new#email.com'),'asda#sdfsd.f', 'new#email.com')
Is there any simple way to do it?
I am not sure why a column would contain an email and other information. So perhaps this does what you want:
update t
set column = 'new#email.com'
where column in ('abd#xyz.com', 'old#re.com', 'asda#sdfsd.f');
If the column contains additional information, I would recommend that you fix your data model rather than trying to make a broken data model work.

Query to select items from a list and update table

I've got a query that I ran against a table of stock items to change a field from false to true so that a label would be printed out as per the below.
UPDATE [StockDB].[dbo].[StockItem]
SET [UseDescriptionOnDocs] = 0
Where [UseDescriptionOnDocs] = 1
I have since been told that all of the items do not need this and to only do it for the ones in a list of 1150. From that I need to modify the query, something which I am really struggling with!, so it can only do it per item which are in the format of R368/WASHER/M4/ZINC/PL etc. I thought I may be able to do it using LIKE but it will only do one line? If I could get it to query a list from Excel or CSV that would be great.
Any pointers would be good as I'm an absolute novice with this once you get past the simple stuff like the above!
Thank you.
With MySQL (and others) you can load data from a file to a table. See http://dev.mysql.com/doc/refman/5.1/en/load-data.html to understand and for exemple.
Once you have your items loaded into a SQL table, you just have to do an update + join query. See http://dev.mysql.com/doc/refman/5.1/en/update.html to understand and How can I do an UPDATE statement with JOIN in SQL? for exemples.

clearing an entire column in access

is there a way to clear an entire column in a datasheet in access? i can just right click on it and delete it but that will affect the structure, i just need to clear all the records. how do i do this?
perhaps the question i should be asking is how do i clear the entire contents of a datasheet in access?
Use an update query, e.g.
UPDATE YourTable
SET YourColumn = NULL
There doesn't seem to be a way to do this directly from the UI, which kind of makes sense.
See
Update data by using a query - Microsoft Office Online
UPDATE table_name
SET field_name = NULL;
Much simpler: right click on the column header in access, select copy. Now go to excel and paste into a excel column. Now hit the delete key, then copy that. Go back to access right click column header and paste. Done.
Note: When selecting what to copy in excel may want to exclude column header or may get extra blank record.
Use Replace All function for CURRENT FIELD, FIND WHAT = * and REPLACE WITH = blank. Took 10 seconds to blank out 22600 records. Make sure you LOOK IN = CURRENT FIELD and that field is highlighted.
right click on upper left square of the datasheet, click DELETE RECORD