I have 4 tables are joind
[dbo].[PersonelInfo](
[pID] [int] IDENTITY(1,1) NOT NULL,
[PersonelCode] [varchar](50) NOT NULL)
[dbo].[EmploymentInfo](
[empID] [int] IDENTITY(1,1) NOT NULL,
[FK_pID] [int] NOT NULL)
ALTER TABLE [dbo].[EmploymentInfo] WITH CHECK ADD CONSTRAINT [FK_EmploymentInfo_PersonelInfo] FOREIGN KEY([FK_pID])
REFERENCES [dbo].[PersonelInfo] ([pID])
[dbo].[ICardDate](
[FK_empID] [int] NOT NULL,
[Imonth] [int] NOT NULL,
[Iyear] [bigint] NOT NULL)
ALTER TABLE [dbo].[ICardDate] WITH CHECK ADD CONSTRAINT [FK_ICardDate_EmploymentInfo] FOREIGN KEY([FK_empID])
REFERENCES [dbo].[EmploymentInfo] ([empID])
[dbo].[PersonelCard](
[pcID] [int] IDENTITY(1,1) NOT NULL,
[FK_empID] [int] NOT NULL,
[FK_month] [int] NOT NULL,
[FK_year] [bigint] NOT NULL,
[VacationHours] [time](7) NULL)
ALTER TABLE [dbo].[PersonelCard] WITH CHECK ADD CONSTRAINT [FK_PersonelCard_ICardDate] FOREIGN KEY([FK_empID], [FK_month], [FK_year])
REFERENCES [dbo].[ICardDate] ([FK_empID], [Imonth], [Iyear])
GO
now I want add a row to [dbo].[PersonelCard] base on my storedprocedure input parameters.
CREATE PROCEDURE [dbo].[InsertRowInPersonelCard]
(@personelcode varchar (50),
@fk_month int,
@fk_year bigint,
@vacationhours time(7))
as
insert into PersonelCard(FK_empID,FK_month,FK_year,VacationHours)
Values(@empID,@fk_month,@fk_year,@vacationhours)
insert into ICardDate(FK_empID,Imonth,Iyear)
Values(@empID,@fk_month,@fk_year)
GO