sqlserver 2000/2005 Ambiguous column error错误解决办法
来源:互联网 发布:知敬畏守规矩作文 编辑:程序博客网 时间:2024/05/21 09:56
今天针对Sql server 2005的脚本在Sql server 2000上执行,发生了两个错误
Msg 209, Level 16, State 1, Procedure tbh_Forums_GetUnapprovedPosts, Line 13
Ambiguous column name 'AddedDate'.
Msg 209, Level 16, State 1, Procedure tbh_Forums_GetThreadByID, Line 13
Ambiguous column name 'AddedDate'.
原来就是Forums表中和Post表中具有相同的列AddedDate,通过as 方式改写就可以解决了
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbh_Forums_GetThreadByID]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[tbh_Forums_GetThreadByID]
(
@ThreadPostID int
)
AS
SET NOCOUNT ON
SELECT tbh_Posts.PostID, tbh_Posts.AddedDate as AddedDate, tbh_Posts.AddedBy, tbh_Posts.AddedByIP, tbh_Posts.ForumID, tbh_Posts.ParentPostID, tbh_Posts.Title, tbh_Posts.Body, tbh_Posts.Approved, tbh_Posts.Closed, tbh_Posts.ViewCount, tbh_Posts.ReplyCount, tbh_Posts.LastPostDate, tbh_Posts.LastPostBy,
tbh_Forums.Title AS ForumTitle
FROM tbh_Posts INNER JOIN
tbh_Forums ON tbh_Posts.ForumID = tbh_Forums.ForumID
WHERE PostID = @ThreadPostID OR ParentPostID = @ThreadPostID
ORDER BY AddedDate ASC'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbh_Forums_GetUnapprovedPosts]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[tbh_Forums_GetUnapprovedPosts]
AS
SET NOCOUNT ON
SELECT tbh_Posts.PostID, tbh_Posts.AddedDate as AddedDate, tbh_Posts.AddedBy, tbh_Posts.AddedByIP, tbh_Posts.ForumID, tbh_Posts.ParentPostID, tbh_Posts.Title, tbh_Posts.Approved, tbh_Posts.Closed, tbh_Posts.ViewCount, tbh_Posts.ReplyCount, tbh_Posts.LastPostDate, tbh_Posts.LastPostBy,
tbh_Forums.Title AS ForumTitle, CASE
WHEN ParentPostID = 0 THEN 1
ELSE 0
END AS IsThreadPost
FROM tbh_Posts INNER JOIN
tbh_Forums ON tbh_Posts.ForumID = tbh_Forums.ForumID
WHERE Approved = 0
ORDER BY IsThreadPost DESC, AddedDate ASC'
END
GO
虽然这样解决了问题,这不应该是问题的真正原因,各位同学谁知道这个问题的真正原因?
- sqlserver 2000/2005 Ambiguous column error错误解决办法
- ambiguous column name解决办法
- ambiguous column name解决办法
- SQL server error: Ambiguous column name
- ERROR 1052 : Column 'eid' in field list is ambiguous
- mysql Error:1052 Column 'xxx' in where clause is ambiguous
- error C2872: 'ofstream' : ambiguous symbol 错误解决
- SQLSERVER 2000 错误823解决办法
- Ambiguous column name
- Ambiguous column name
- Ambiguous column name
- sqlserver报“ResultSet can not re-read row data for column”错误的解决办法
- 使用duilib出现“error C2872: 'CRect' : ambiguous symbol”等错误
- 用sql server2005的错误 java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. 解决办法
- QT笔记:ambiguous column name:
- sqlite: ambiguous column name解决方法
- ERROR: 'fstream' : ambiguous symbol
- error MSB3073 错误解决办法
- "Ascend.Net" Windows Forms Controls
- 十天学会php之第十天
- ----------------------------MSSQL多列取最大或者最小值---------------
- Sql Server 2005 ROW_NUMBER 函数实现分页
- Google免费主页服务
- sqlserver 2000/2005 Ambiguous column error错误解决办法
- 用Eclipse MyEclipse WebLogic8.1开发第一个Web程序
- 搭建.net framwork 3.0开发环境的一篇文章
- Mono 开发者会议
- VMware Player测试Mono应用
- 利用VS2005中的Code Snippets提高开发效率
- HTML标记应用
- NDoc 死了,微软推出Sandcastle - 托管类库文档编译器
- 区域设置 ID (LCID) 表