Here is the trigger codeALTER TRIGGER dbo.trg_DescUpdateON dbo.NewProductFOR INSERT, UPDATEASSET NOCOUNT ON;IF UPDATE(Prod_c_Family) OR UPDATE(Prod_Name) OR UPDATE(Prod_c_Type) OR UPDATE(Prod_c_Height) OR UPDATE(Prod_c_PotSize) OR UPDATE(Prod_c_PlantOrPot) UPDATE np SET np.Prod_c_Description = i.Prod_c_Family + ' ' + i.Prod_Name + ' ' + i.Prod_c_Type + CASE Prod_c_PlantOrPot WHEN 'Plant' THEN ' H' + CAST(i.Prod_c_Height AS NVARCHAR(20) + ' P' + i.Prod_c_PotSize ELSE ' H' + CAST(i.Prod_c_Height AS NVARCHAR(20) + ' W' + CAST(i.Prod_c_Width AS NVARCHAR(20) + ' D' + CAST(i.Prod_c_Depth AS NVARCHAR(20) END FROM dbo.NewProduct AS np INNER JOIN inserted AS i ON i.Prod_ProductID = l.Prod_ProductID;GO
But you really don't need a trigger for this. Use a calculated column and make it persisted if needed.ALTER TABLE dbo.NewProduct DROP COLUMN Prod_c_Description;ALTER TABLE dbo.NewProduct ADD Prod_c_Description AS ISNULL(i.Prod_c_Family + ' ' + i.Prod_Name + ' ' + i.Prod_c_Type + ' H' + CAST(i.Prod_c_Height AS NVARCHAR(20)) + CASE WHEN Prod_c_PlantOrPot = 'Plant' THEN ' P' + i.Prod_c_PotSize ELSE ' W' + CAST(i.Prod_c_Width AS NVARCHAR(20)) + ' D' + CAST(i.Prod_c_Depth AS NVARCHAR(20)) END, '') PERSISTED;
Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA