本文介绍了mssql中的无效对象错误 - 消息208的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
执行查询时出现无效对象错误。
请帮忙!
========== =====================
There is an Invalid Object error while executing query.
Please help !
===============================
USE HR_Employee
GO
DECLARE @SQLQuery AS NVARCHAR(MAX)
DECLARE @PivotColumns AS NVARCHAR(MAX)
SELECT @PivotColumns= COALESCE(@PivotColumns + ',','') + QUOTENAME(ADA_DATE)
FROM (SELECT DISTINCT ADA_DATE FROM WrkDailyAttend_Web) AS PivotExample
SELECT @PivotColumns
SET @SQLQuery = N'SELECT EMP_ID, ' + @PivotColumns + '
FROM [HR_Employee].[dbo].[PivotExample]
PIVOT (MAX(TIME_IN) FOR ADA_DATE IN (' + @PivotColumns + ')) AS P'
SELECT @SQLQuery
EXEC sp_executesql @SQLQuery
================== =====================
结果:
(1排) (s)受影响)
(受影响的1行)
消息208,级别16,状态1,行1
无效的对象名称'HR_Employee.dbo.PivotExample'。
=======================================
Result :
(1 row(s) affected)
(1 row(s) affected)
Msg 208, Level 16, State 1, Line 1
Invalid object name 'HR_Employee.dbo.PivotExample'.
推荐答案
这篇关于mssql中的无效对象错误 - 消息208的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!