I have the following store procedure in the DDT
@pEmployeePK INT,@pServiceCallsScheduleDate DATETIMEASSELECT DISTINCT dbo.ServiceCalls.*FROM dbo.ServiceCallsRIGHT OUTER JOIN dbo.SC_AppliancesON (dbo.ServiceCalls.PK_ServiceCalls = dbo.SC_Appliances.FK_ServiceCalls)WHERE (dbo.ServiceCalls.Status NOT IN (2,3))AND (dbo.SC_Appliances.IncludeInSCRoute = 1)AND (dbo.SC_Appliances.FK_Employees = @pEmployeePK)AND (dbo.SC_Appliances.ServicedDate = @pServiceCallsScheduleDate);SELECT DISTINCT dbo.SC_Appliances.* FROM dbo.SC_AppliancesRIGHT OUTER JOIN dbo.ServiceCallsON (dbo.SC_Appliances.FK_ServiceCalls = dbo.ServiceCalls.PK_ServiceCalls)WHERE (dbo.ServiceCalls.Status NOT IN (2,3))AND (dbo.SC_Appliances.IncludeInSCRoute = 1)AND (dbo.SC_Appliances.FK_Employees = @pEmployeePK)AND (dbo.SC_Appliances.ServicedDate = @pServiceCallsScheduleDate);
@pEmployeePK
@pServiceCallsScheduleDate
AS
SELECT
FROM
WHERE
The parameter @pEmployeePK should be optional, which mean, that I can either pass a value or pass 0, in VB code I would simple do something like this:
If tEmployeePK > 0 Then cmd.Parameters.AddWithValue("@pEmployeePK", tEmployeePK).SqlDbType = SqlDbType.BigIntEnd If
If
cmd.Parameters.AddWithValue(
How would I code the same condition in T-SQL for the store procedure?