Hello, question about INSERT INTO statement. Is it possible to use insert into statement with SELECT to copy data from one column to a new column in MS SQL? I am including a link to a related question I have for the experts.
INSERT INTO does not copy from one column to another in existing columns, It inserts extra rows.
It sounds like what you want is
UPDATE tablename
SET column1 = column2
WHERE ...
Jim Horn
<somewhat redundant with the above post>
INSERT adds new rows to a table, either by using a SELECT statement, or entering VALUES.
UPDATE modifies existing rows in a table.
So ... give us a data mockup of exactly what you are trying to pull off here, with better definition of 'one column' and 'new column'.
blackcatkempo
ASKER
I would like to populate a new column labeled "hostname", which is DNS resolution of the host column. The hostname column should only have hostnames per row. The hostname can be found in the [plugin output] column for each row. To find the correct row aligning with correct [plugin output] (hostname); the row will have a [plugin id] labeled - 55472. Attached is sample data file. 28589163SAMPLE-DATA3.csv
Yes the traceroute is accurate, but its not a one-to-one mapping. The sample file I attached unfortunately only has a single hostname to ip mapping. The full table (not attached) lists 10K hosts each with a mapped hostname using Plugin Id - 55472. I need the code to copy the hostname from plugin output column to a new column labeled "hostname". Having a dedicated column with mapped hostname will help immensely.
It sounds like what you want is
UPDATE tablename
SET column1 = column2
WHERE ...