本文介绍了存储过程 - 列名无效但实际上存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的存储过程出现此错误:消息207,级别16,状态1,过程spGetAllEvents,第31行无效的列名称'EventAccessIds'。
EventAccessIds确实存在。我不知道应该怎么做才能解决这个问题。<
I get this error for my Stored Procedure: Msg 207, Level 16, State 1, Procedure spGetAllEvents, Line 31 Invalid column name 'EventAccessIds'.
EventAccessIds does exist though. I don't see what I should do to fix this.<
USE [Events2]
GO
/****** Object: StoredProcedure [dbo].[spGetAllEvents] Script Date: 11/19/2015 9:03:42 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
ALTER PROCEDURE [dbo].[spGetAllEvents]
@UserName nVarChar(255)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
WITH first AS
(
SELECT EventAccessIds
FROM Users
WHERE UserName = @UserName
), second AS
(
SELECT *
FROM Event
WHERE EventId IN (SELECT CONVERT(int, Data) FROM dbo.Split(EventAccessIds, '+')
)
)
SELECT *
FROM first f JOIN second s
ON f.EventAccessIds = s.EventId
END
推荐答案
SELECT CONVERT(int, Data) FROM dbo.Split(EventAccessIds, '+')
但是,我们看不到任何结构或你的数据库,所以你必须弄清楚它指向哪一个并修复它。
However, we can't see any of the structure or your db so you'll have to figure out which one it is pointing to and fix it.
这篇关于存储过程 - 列名无效但实际上存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!