Error Trigger. The multi-part identifier "..." could not be bound

I'm trying to do an UPDATE using a TRIGGER.

I have 2 Databases (eBob and Sbmx_taslado) in which they share information, material and density.

What I'm trying to make is that when you change the density of a material (database Sbmx_traslado) this is updated (eBob database).

The problem is that the table is updated where the material can be repeated the same in different container, which sends me the following error:

(Excuse my English, use google)

enter image description here

Use Sbmx_traslado
GO

CREATE TRIGGER DensidadMaterial2
ON  [Sbmx_traslado].[dbo].[Sbmx_Contenedores]
AFTER UPDATE
AS
UPDATE [eBob].[dbo].[tblVessel]
SET [eBob].[dbo].[tblVessel].[ProductDensityWeight] = [Sbmx_traslado].[dbo].[Sbmx_Contenedores].[Densidad]
FROM [Sbmx_traslado].[dbo].[Sbmx_Contenedores]
WHERE [eBob].[dbo].[tblVessel].[Contents] = [Sbmx_traslado].[dbo].[Sbmx_Contenedores].[Ingrediente]

Upvotes: 0

Views: 352

Answers (1)

dbbri
dbbri

Reputation: 224

You're referencing a table in the WHERE clause that is not in the FROM. Try this.

Use Sbmx_traslado
GO

CREATE TRIGGER DensidadMaterial2
ON  [Sbmx_traslado].[dbo].[Sbmx_Contenedores]
AFTER UPDATE
AS
UPDATE [eBob].[dbo].[tblVessel]
SET [eBob].[dbo].[tblVessel].[ProductDensityWeight] = [Sbmx_traslado].[dbo].[Sbmx_Contenedores].[Densidad]
FROM [eBob].[dbo].[tblVessel]
JOIN [Sbmx_traslado].[dbo].[Sbmx_Contenedores] ON [eBob].[dbo].[tblVessel].[Contents] = [Sbmx_traslado].[dbo].[Sbmx_Contenedores].[Ingrediente]

Upvotes: 1

Related Questions