Voici ma procédure stockée ci-dessous. Je concatène @CultureCode
paramter avec le nom de vue qui est [_0002HR_EmployeeNames_ en-US _View]. La partie en-US sera passée à travers un paramètre nommé @CultureCode
. Est-il possible de le faire parce que j'ai l'obligation de ne pas utiliser la requête dynamique. Je vous remercie.Comment passer le nom de vue dynamique dans une procédure stockée SQL sans utiliser de requête dynamique?
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)
Tag dbms produit utilisé. (Ne ressemble pas du tout à ANSI SQL ...) – jarlh