try
ELECT Distinct StockInBranches.ItemCode,StockInBranches.BranchName,StockInBranches.Price,StockInBranches.Qty
FROM StockInBranches
Inner Join ItemMaster On
StockInBranches.ItemCode= ItemMaster.ItemCode
WHERE StockInBranches.BranchName=@BranchName and (@ItemCode is null or StockInBranches.ItemCode = @ItemCode)
if you only need to pass BranchName only then
ELECT Distinct StockInBranches.ItemCode,StockInBranches.BranchName,StockInBranches.Price,StockInBranches.Qty
FROM StockInBranches
Inner Join ItemMaster On
StockInBranches.ItemCode= ItemMaster.ItemCode
WHERE StockInBranches.BranchName=@BranchName