I want to inner join only if my condition satisfies. In the given code my if condition is failing. I'm new to stored procedures. Can anyone help me with how I can write if condition based on my request? Thanks in advance.
INNER JOIN
IF(@Country IS NOT NULL) OR (LEN(@Country) > 0)
BEGIN
(SELECT A, s.B, s.C, s.D, sv.D FROM [AM].[dbo].[XYZ] s
INNER JOIN [PM].[dbo].[ABC] sv
ON s.A = sv.D collate SQL_Latin1_General_CP1_CI_AS where Country= @Country) TABLE
ON RO.OByID = TABLE.Id
END
ElSE
BEGIN
INNER JOIN Table2 ON RO.OByID = Table2.Id
END
INNER JOIN (GTGTG)
INNERJOING(GDGF)
...Etc
Aucun commentaire:
Enregistrer un commentaire