Hi,
I am trying to change an SP from dynamic SQL to proper SQL but I can't
figure a way to conditionally add extra parts to the statement. How
can I do the equivalent of the following?
DECLARE @arg NVARCHAR(10)
SELECT a.i, a.x
FROM aTable a
IF LEN(@arg)
BEGIN
INNER JOIN bTable b ON a.[id] = b.[id]
END
Conditionally adding the INNER JOIN is very easy when building up a SQL
string but I can't see how to do it in pure SQL?
Thanks.
I am trying to change an SP from dynamic SQL to proper SQL but I can't
figure a way to conditionally add extra parts to the statement. How
can I do the equivalent of the following?
DECLARE @arg NVARCHAR(10)
SELECT a.i, a.x
FROM aTable a
IF LEN(@arg)
BEGIN
INNER JOIN bTable b ON a.[id] = b.[id]
END
Conditionally adding the INNER JOIN is very easy when building up a SQL
string but I can't see how to do it in pure SQL?
Thanks.
Comment