2014-07-09 52 views
0

爲什麼SSRS會拋出一個錯誤,指出在我的少於符號附近存在不正確的語法?'<'附近的語法錯誤'

-- ========================================================== 
-- Create Stored Procedure Template for SQL Azure Database 
-- ========================================================== 
SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
-- ============================================= 
-- Author:  <Campos,,Adrian> 
-- Create date: <7/9/2014,,> 
-- Description: <Query is meant to purge records in ONP_IL_MAYWOOD that are older than 3 months.,,> 
-- ============================================= 
CREATE PROCEDURE <Purge_Overnight_3Months, sysname, Purge_Overnight_3Months> 
-- Add the parameters for the stored procedure here 

AS 
BEGIN 
-- SET NOCOUNT ON added to prevent extra result sets from 
-- interfering with SELECT statements. 
SET NOCOUNT ON; 

-- Insert statements for procedure here 
DELETE FROM tblOverNightPermissions WHERE DateAndTime < DATEADD(month, -3, GETDATE()); 
END 
GO 

錯誤:

Msg 102, Level 15, State 1, Line 6
Incorrect syntax near '<'.

+0

您的查詢看起來是正確的。你確定這是一個嗎? –

+1

這是說第6行,你的查詢中是這6行嗎? –

+0

@KrisGruttemeyer這讓我感到困惑。對不起,我不夠清楚。上面的第6行是'SET QUOTED_IDENTIFIER ON',但是它抱怨第23行的'<'字符 – Adrian

回答

0

使用[]逃跑的名字在TSQL,不<>

CREATE PROCEDURE [Purge_Overnight_3Months, sysname, Purge_Overnight_3Months] 

,但你不應該無論如何使用這樣奇怪的名字。如何?

CREATE PROCEDURE Purge_Overnight_3Months 
+0

這個伎倆! SSRS默認使用此模板包含'<'謝謝。 – Adrian

1

<Purge_Overnight_3Months, sysname, Purge_Overnight_3Months>是Management Studio的模板參數。在SSMS中打開文件時,按Ctrl-Shift-M(或從查詢菜單中選擇「爲模板參數指定值...」)。這應該會顯示一個網格,其中有一個名爲Purge_Overnight_3Months(尖括號中的第一個值)的參數,其數據類型爲sysname,默認值爲「Purge_Overnight_3Months」(尖括號中的第三個值)。一旦你指定了一個值,並點擊「確定」,它將用你選擇的值代替整個尖括號。