Ce code:SQL Server 2005 - L'identifiant plusieurs parties ne pouvait être liée
USE [db]
GO
/****** Object: UserDefinedFunction [dbo].[GetFieldPickerReports] Script Date: 01/11/2013 19:12:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[GetFieldPickerReports] (@CustomerName varchar(100))
RETURNS TABLE
AS
RETURN SELECT [fpr].[ID], [fpr].[Name], [fpr].[Global], [fpr].[FPRCategoryID]
FROM FieldPickerReport fpr, dbo.GetProductKeyIdByCustomer(@CustomerName) pk
LEFT JOIN [FPRCategory] fprcat on ([fpr].[FPRCategoryID]=[fprcat].[ID])
WHERE [Global]=1 OR ProductKeyID=pk.id
génère une erreur:
The multi-part identifier "fpr.FPRCategoryID" could not be bound.
Cette requête fonctionne sans Left Join
(dont j'ai besoin actuellement d'ajouter) ou avec la suppression de dbo.GetProductKeyIdByCustomer()
et la clause Where
.
Voici le code pour dbo.GetProductKeyIdByCustomer()
USE [db]
GO
/****** Object: UserDefinedFunction [dbo].[GetProductKeyIdByCustomer] Script Date: 01/11/2013 19:58:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[GetProductKeyIdByCustomer] (@CustomerName varchar(100))
RETURNS TABLE
AS
RETURN SELECT id
FROM ProductKey
WHERE [CustomerName][email protected] AND Enabled=1
Quel est le problème avec ma requête?
Y a-t-il une logique à laquelle les noms sont mis entre crochets? –
@MrLister Peut-être le développeur précédent avec lequel je n'ai aucun contact. – Dante