Incorrect syntax near '<'

狂风中的少年 提交于 2019-12-11 21:07:52

问题


Why is SSRS throwing an error stating that there is an incorrect syntax near my less than symbol?

-- ==========================================================
-- 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

Error:

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


回答1:


Use [] to escape names in TSQL, not <>

CREATE PROCEDURE [Purge_Overnight_3Months, sysname, Purge_Overnight_3Months]

but you should not use such strange names anyway. How about

CREATE PROCEDURE Purge_Overnight_3Months



回答2:


The <Purge_Overnight_3Months, sysname, Purge_Overnight_3Months> is a template parameter for Management Studio. While the file is opened in SSMS hit Ctrl-Shift-M (or choose "Specify Values for Template Parameters…" from the Query Menu). This should bring up a grid that says that there's parameter called Purge_Overnight_3Months (the first value in the angle brackets) with a datatype of sysname and a default value of "Purge_Overnight_3Months" (the third value in the angle brackets). Once you specify a value, and hit "ok", it will replace the entire angle brackets with the value that you chose.



来源:https://stackoverflow.com/questions/24661805/incorrect-syntax-near

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!