好的我有2個問題1)我用google搜索了這個錯誤(標題)但我似乎無法幫助我,我PROC:SQL:Msg 156,Level 15,State 1:關鍵字'END'附近的語法不正確
CREATE PROCEDURE [dbo].[p_Target]
AS
BEGIN
ET NOCOUNT ON
CREATE TABLE #tmp1
(
AUD_ID BIGINT,
RowCounter BIGINT,
DistinctCounter BIGINT,
NACounter BIGINT,
Total BIGINT,
[Status] VARCHAR(MAX)
)
INSERT INTO #tmp1 EXEC [p_GetCompleteIncompleteNaOverviewSCORE]
DECLARE @Total AS INT
SELECT @Total = COUNT(*)
FROM (
SELECT CASE WHEN CONVERT(DATETIME,CONVERT(CHAR(10),DATEADD(DAY,0,t2.AUD_TargetDate), 101)) < CONVERT(DATETIME,CONVERT(CHAR(10),DATEADD(DAY,0,GETDATE()), 101))
THEN 'Over Due: '
ELSE 'On Time: ' END AS [Target Status]
FROM #tmp1 t1 INNER JOIN dbo.Audit t2
ON t1.AUD_ID = t2.AUD_ID
WHERE t1.[Status] = 'Open') DER
SELECT ([Target Status] + '' + CAST(COUNT(*) AS NVARCHAR(255)) + ' of ' + CAST(@Total AS NVARCHAR(255))) AS TargetStatus, (SELECT COUNT(*)) * 100/(SELECT ([Target Status] + '' + CAST(COUNT(*) AS NVARCHAR(255))) AS [Count]
FROM (
SELECT CASE WHEN CONVERT(DATETIME,CONVERT(CHAR(10),DATEADD(DAY,0,t2.AUD_TargetDate), 101)) < CONVERT(DATETIME,CONVERT(CHAR(10),DATEADD(DAY,0,GETDATE()), 101))
THEN 'Over Due: '
ELSE 'On Time: ' END AS [Target Status]
FROM #tmp1 t1 INNER JOIN dbo.Audit t2
ON t1.AUD_ID = t2.AUD_ID
WHERE t1.[Status] = 'Open') DER
GROUP BY [Target Status]
END
GO
我綁加入),以NVARCHAR(255))) AS [Count]
但仍然錯誤, 2)我需要得到AS [Count]
作爲percentag,如果有人能幫助?這是我的嘗試代碼,也許我在正確的軌道上。?
'ET NOCOUNT ON'缺少'S'是一個錯字? – Satpal
這是粘貼錯誤。 – inzefinite