我在SQL 2012中工作。我曾经在SQL 2008 R2上的单个表视图上使用交叉应用命令。我正在做一个多表视图,并尝试使用交叉应用,我收到一个错误。我不确定连接是否导致问题,或者它是否与CROSS APPLY相关。
以下是以前的工作:
CREATE VIEW [dbo].[AttributeValues_VW]
AS
select userProfileID, Name, Item
from dbo.AttributeValues
cross apply dbo.udf_Split(Value,',') as Item;
GO
以下是我的尝试:
Create View [dbo].[DistrictManager_VW] AS
Select Distinct AV.UserProfileID, AV.Name, AV.Value, UP.EmailAddress, MR.RoleID
From Mup_UserAttributeValue AV
Join Mup_UserProfile UP on AV.UserProfileID=UP.UserProfileID
Join Mup_Role MR on MR.UserProfileID=AV.UserProfileID
Join Main_Form MF on MF.[Primary Email]=UP.EmailAddress
Where RoleID=267
cross apply dbo.udf_Split(AV.Value,',') as Item;
Go
答案 0 :(得分:0)
cross apply
进入from
子句:
Create View [dbo].[DistrictManager_VW] AS
Select Distinct AV.UserProfileID, AV.Name, AV.Value, UP.EmailAddress, MR.RoleID
From Mup_UserAttributeValue AV Join
Mup_UserProfile UP
on AV.UserProfileID = UP.UserProfileID Join
Mup_Role MR
on MR.UserProfileID = AV.UserProfileID Join
Main_Form MF
on MF.[Primary Email] = UP.EmailAddress
cross apply dbo.udf_Split(AV.Value, ',') as Item;
Where RoleID = 267;
但是,您似乎没有使用Item
。应该在select
条款中。