存储过程出现错误.关键字'ORDER'附近有语法错误.')'附近有语法错误.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了存储过程出现错误.关键字'ORDER'附近有语法错误.')'附近有语法错误.相关的知识,希望对你有一定的参考价值。
ALTER PROCEDURE [getArticles]
@keyword varchar(20),
@startRowIndex int,
@maximumRows int,
@categoryID int,
@totalRows int output,
@preRowIndex int output,
@nextRowIndex int output
AS
DECLARE @first_id int,@startRow int
SET @startRowIndex = (@startRowIndex-1)*@maximumRows
IF @startRowIndex = 0
SET @startRowIndex = 1
SET ROWCOUNT @startRowIndex
if @keyword=''
SELECT @first_id = ID FROM article where categoryID=@categoryID ORDER BY ID
else SELECT @first_id = ID FROM article where categoryID=@categoryID and title like '%'+@keyword+'%' ORDER BY ID
PRINT @first_id
SET ROWCOUNT @maximumRows
if @keyword=''
(
SELECT * FROM [article] WHERE ID>=@first_id and categoryID=@categoryID ORDER BY ID
SELECT @preRowIndex=max(ID) FROM [article] WHERE ID>=@first_id-@maximumRows and ID<@first_id
SELECT @nextRowIndex=max(ID) FROM [article] WHERE ID>=@first_id+@maximumRows and ID<@first_id+2*@maximumRows
)
else SELECT * FROM [article] where ID>=@first_id and categoryID=@categoryID and title like '%'+@keyword+'%' ORDER BY ID
SET ROWCOUNT 0
if @keyword=''
SELECT @totalRows = COUNT(ID) FROM [article] where categoryID=@categoryID
else SELECT @totalRows = COUNT(ID) FROM [article] where categoryID=@categoryID and title like '%'+@keyword+'%'
string
sql
="insert
into
[order]
([username],flag,ordertime)
values(
'"
+
session["username"].tostring()
+
"','"
+
0
+"',
convert(datetime,'"
+
datetime.today.toshortdatestring()
+
"',120))"; 参考技术B 把 ( 换成begin,把 ) 换成end ,一切OK ,我在我这边测试过了,保证没问题本回答被提问者采纳
以上是关于存储过程出现错误.关键字'ORDER'附近有语法错误.')'附近有语法错误.的主要内容,如果未能解决你的问题,请参考以下文章
存储过程 Advantage Database SQL 中出现错误的意外令牌
在应使用条件的上下文(在 'where' 附近)中指定了非布尔类型的表达式。 关键字 'order' 附近有语法错误。
JFinal项目eclipse出现Unknown column 'createtime' in 'order clause' 的错误