2
此代碼:的SQL Server 2005 - 多部分組成的標識符無法綁定
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
產生一個錯誤:
The multi-part identifier "fpr.FPRCategoryID" could not be bound.
該查詢作品,未經Left Join
(這是我目前需要添加)或者刪除dbo.GetProductKeyIdByCustomer()
和Where
條款。
下面是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
有什麼不對我的查詢代碼?
是否存在將方括號中的名稱放入哪個邏輯? –
@MrLister也許以前的開發者與我沒有聯繫。 – Dante