Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Having Trouble Copying data from one table to another SQL Server

$
0
0

I have two tables one is called: tblLocation the other is called TempImport2. TempImport2 and tblLocation both tables have columns named LocationNumber, Lattitude, Longitude. tblLocation has more unrelated columns whereas TempImport2 has no other columns. Not every LocationNumber found in tblLocation resides in the table TempImport2, but over 8000 records do match. I want to update tblLocation.Latitude to equal the matching value found in TempImport2.Latitude. Here is what I have for my Query:

UPDATE tblLocation
SET Latitude = (
SELECT Latitude
FROM TempImport2
WHERE TempImport2.LocationNumber = tblLocation.LocationNumber);

Here are the results of the Query:

Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'Latitude', table '[databaseName].tblLocation'; column does not allow nulls. UPDATE fails.
The...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>