Dynamic Update Query

filobetty

New member
Local time
Today, 08:28
Joined
Feb 19, 2014
Messages
1
Hello All.

I need help and direction with something along the lines of an update query, but where the update is dynamic, rather than static.

I am neither a database/SQL or programming expert so go easy on me!!

I have written a query to select the records in a single table that need updating but don’t know how to update since it is not a simple update query.

The query returns for example:
Hostname | Port Name
switchABC | switchABC_Ethernet100/1/1
switchABC | switchABC_Ethernet100/1/2
switchDEF | switchABC_Ethernet101/1/1

For all records that the query matches, I want to extract the “100” from the Port Name, and append to the hostname to achieve a new hostname of “switchABC-100”
At the moment I’m not sure where to start?
 
Code:
 I want to extract the “100” from the Port Name, and append to the hostname to achieve a new hostname of “switchABC-100”

I'd start by reading up on normalization: http://en.wikipedia.org/wiki/Database_normalization

What you said you want to do and what you currently have, are not how databases are to work. In tables, you need to store your discrete pieces of data in their own fields. That means the 100/1/1 data should be in 3 fields because obviously the 100 is a discrete piece of data.

Then when you need to use your data, you don't update a field in a table, you simply create a query to concatenate (combine strings) the data together.
 

Users who are viewing this thread

Back
Top Bottom