Updating a Column from another table and my attempts are queuing the same data that's already in Speedlink_ID I am trying to Update CON_SP_ID from CON_SP_ID Table 1 CON_SP_ID all rows are blank or NULL Table 2*Speedlink_ID* has the data
Both columns have the same amount of rows.
ATTEMPT 1 - Returns no updated data.
UPDATE t1
SET CON_SP_ID = t2.Speedlink_ID
FROM dbo.Data1 AS t1
INNER JOIN dbo.Data2 AS t2
ON t1.CON_SP_ID = t2.[Speedlink_ID]
SELECT TOP (1000) [CON_SP_ID]
FROM Data1
ATTEMPT 2
UPDATE t -- alias of table you are updating
SET CON_SP_ID = d.Speedlink_ID
FROM Data1 t
join Data2 d on d.Speedlink_ID = t.CON_SP_ID
SELECT TOP (1000) [CON_SP_ID]
FROM [Data1]
ATTEMPT 3
UPDATE [Data1]
SET [Data1].CON_SP_ID = (
SELECT CON_SP_ID
FROM [DATA2]
WHERE [Data1].CON_SP_ID = [DATA2].CON_SP_ID)
SELECT TOP (1000) [CON_SP_ID]
FROM [Data1]
ATTEMPT 4 - Repeats first ROW of [DATA2].[Speedlink_ID] to the end of the table
UPDATE [Data1]
SET [Data1].CON_SP_ID = [DATA2].[Speedlink_ID]
FROM [DATA2]
SELECT TOP (1000) [CON_SP_ID]
FROM [Data1]
Thanks @avery_larry
I did realize you needed a column that is the same on both tables. Subnet is in the same sort order / entered in the same way as my 2nd table. I needed to match row for row using the subnet and my KEY because its a Unique number.
Still learning, thx every one
UPDATE [Data1]
SET [Data1].[CON_SP_ID] = [Data2].[Con_SP_ID]
FROM
dbo.Data1 as Data1
INNER JOIN
dbo.Data2 AS Data2
ON
Data1.Subnet = Data2.Subnet
SELECT TOP (1000) [CON_SP_ID]
FROM [Data1]