A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi @Analyst_SQL ,
Sorry that I am confused.
I also tried below when #tbl_Grn_Detail Col Issue_ID is not null, tbl_issuance is not inserted:
drop table if exists tbl_GRN_Detail,tbl_issuance
Create table tbl_GRN_Detail (D_ID int,GRN_ID int,item_code int,Issue_ID int)
Insert into tbl_GRN_Detail values (11001,2001,22,1)
Create table tbl_issuance (issue_ID int,item_code int,Issue_Date date,D_ID int)
GO
DECLARE @D_ID int=11001
DECLARE @Issue_ID INT=101
IF NOT EXISTS(Select 1 from tbl_GRN_Detail where D_ID=@D_ID and Issue_ID is NOT null)
begin
Insert into tbl_issuance values (@Issue_ID,22,'2021-06-28',@D_ID)
end
select * from tbl_GRN_Detail
select * from tbl_issuance
i am saying ,when #tbl_Grn_Detail Col Issue_ID is not null ,then row should not insert into table #tbl_Issuance
Does above also mean that only when #tbl_Grn_Detail Col Issue_ID is null, then #tbl_Issuance could be inserted?
It could be better to provide some sample data with both conditions(should not insert and should insert) so that I could understand better.
Thank you for understanding!
Best regards,
Melissa