Here is my stored procedure below. I am concatenating @CultureCode paramter along with view name which is [_0002HR_EmployeeNames_en-US_View]. The part en-US will be passed through a parameter named as @CultureCode. Is there any way to do so because i have requirement not to use dynamic query. Thank you.
CREATE PROCEDURE [dbo].[_001HR_Report_Loans] (@Parameters VARCHAR(max))
AS
DECLARE @ReportOption VARCHAR(5) SET @ReportOption = [dbo].DB_Split(@Parameters, 1)
DECLARE @CultureCode VARCHAR(10) SET @CultureCode = [dbo].DB_Split(@Parameters, 2)
DECLARE @ShowItems VARCHAR(5) SET @ShowItems = [dbo].DB_Split(@Parameters, 3)
DECLARE @StartDate NVARCHAR(8) SET @StartDate = [dbo].DB_Split(@Parameters, 4)
DECLARE @EndDate NVARCHAR(8) SET @EndDate = [dbo].DB_Split(@Parameters, 5)
DECLARE @EmployeeCode NVARCHAR(30) SET @EmployeeCode = [dbo].DB_Split(@Parameters, 6)
DECLARE @BranchCode NVARCHAR(30) SET @BranchCode = [dbo].DB_Split(@Parameters, 7)
--IF @StartDate = ''
-- SET @StartDate = NULL
SELECT HR.*, EN.[Name] AS EmployeeName
FROM [0002HR_EmployeeLoans] HR
LEFT JOIN [_0002HR_EmployeeNames_ + '@CultureCode' +_View] EN ON HR.EmployeeCode = EN.EmployeeCode
LEFT JOIN [_0002HR_EmployeePackagesView] EP ON EP.EmployeeCode = HR.EmployeeCode
WHERE
(HR.EmployeeCode = @EmployeeCode OR @EmployeeCode IS NULL)
AND
(EP.BranchCode = @BranchCode OR @BranchCode IS NULL)
AND
(HR.Date BETWEEN @StartDate AND @EndDate OR @StartDate IS NULL AND @EndDate IS NULL)
AND
(HR.Date >= @StartDate OR @StartDate IS NULL)
AND
(HR.Date <= @EndDate OR @EndDate IS NULL)