ok sorry I'll explain further, I have a database that has a table for terminated employees and I need to get data from one database to another.
the TM# is the primary key in the Termination table [GamingCommissiondb] and the Employee is the primary key [Test]in the DesireeTerm3 table Data type on both is INT
Code:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER PROCEDURE InsertTermsReasons
AS
INSERT INTO [Test].[dbo].[TERMINATION] (
[TM #], [Reasonfortermination]
) SELECT
a.[Employee], a.[DESCRIPTION]
FROM DesireeTerm3 AS a
WHERE a.ACTION_CODE = 'TERM'
AND NOT EXISTS (SELECT *
FROM [Test].[dbo].[TERMINATION] AS z
WHERE z.[TM #] = a.[Employee])
RETURN
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO