Reputation: 713
I want to copy one table column value to another table. But both are in different databases. I did this but
UPDATE dbo.Excelimp.Furniture
SET dbo.Excelimp.Furniture.AssetId = dbo.Sample.FADetailsNew.AssetNo
FROM dbo.Excelimp.Furniture
JOIN Sample
ON dbo.Excelimp.Furniture.AssetName=dbo.Sample.FADetailsNew.AssetName
but it seems the error
Invalid object name 'dbo.Excelimp.Furniture'.
Upvotes: 2
Views: 88
Reputation: 3656
Try this one:
UPDATE Furniture
SET Furniture.AssetId = T2.AssetNo
FROM Sample.dbo.FADetailsNew AS T2
WHERE Furniture.AssetName = T2.AssetName
Upvotes: 0
Reputation: 1
Firstly,Invalid error objects is coming because SQL server did not had that Object.Below query shows all the objects present in the Database.
SELECT name AS object_name
,SCHEMA_NAME(schema_id) AS schema_name
,type_desc
,create_date
,modify_date
FROM sys.objects
GO
. Specify your database name,Schema Name, table name and column name.
Try removing "dbo." from your code and run it.
Upvotes: 0
Reputation: 6088
No Need of writing schema with column name you can write as below also
UPDATE T1
SET T1.AssetId = T2.AssetNo
FROM Excelimp.Furniture T1
JOIN Sample.FADetailsNew T2
ON T1.AssetName=T2.AssetName
Upvotes: 1