SQL存储过程中 错误156:在关键字‘set’附近有语法错误
SQL2000的存储过程如下,检查时老是出现错误156:在关键字‘set’附近有语法错误,请高手指导。CREATEPROCEDURE[test]asDeclare@nin...
SQL2000的存储过程如下,检查时老是出现错误156:在关键字‘set’附近有语法错误,请高手指导。
CREATE PROCEDURE [test]
as
Declare @n int
Declare @ct datetime
set @n=-30
while @n<0
begin
set @ct=DATEADD(DAY,@n, GETDATE())
INSERT INTO AI
SELECT AVG (f1) AS f1, AVG (f2) AS f2, AVG (f3) AS f3, @ct AS dt
FROM demo
WHERE (YEAR(dt)=YEAR(@ct) AND (Month(dt)=MONTH(@ct) AND (Day(dt)=DAY (@ct)
set @n=@n+1
end
go
CREATE PROCEDURE [test]
as
Declare @n int
Declare @ct datetime
set @n=-30
while @n<0
begin
set @ct=DATEADD(DAY,@n, GETDATE())
INSERT INTO AI
SELECT AVG (f1) AS f1, AVG (f2) AS f2, AVG (f3) AS f3, @ct AS dt
FROM demo
WHERE (YEAR(dt)=YEAR(@ct))AND (Month(dt)=MONTH(@ct)) AND (Day(dt)=DAY (@ct))
set @n=@n+1
end
go 展开
CREATE PROCEDURE [test]
as
Declare @n int
Declare @ct datetime
set @n=-30
while @n<0
begin
set @ct=DATEADD(DAY,@n, GETDATE())
INSERT INTO AI
SELECT AVG (f1) AS f1, AVG (f2) AS f2, AVG (f3) AS f3, @ct AS dt
FROM demo
WHERE (YEAR(dt)=YEAR(@ct) AND (Month(dt)=MONTH(@ct) AND (Day(dt)=DAY (@ct)
set @n=@n+1
end
go
CREATE PROCEDURE [test]
as
Declare @n int
Declare @ct datetime
set @n=-30
while @n<0
begin
set @ct=DATEADD(DAY,@n, GETDATE())
INSERT INTO AI
SELECT AVG (f1) AS f1, AVG (f2) AS f2, AVG (f3) AS f3, @ct AS dt
FROM demo
WHERE (YEAR(dt)=YEAR(@ct))AND (Month(dt)=MONTH(@ct)) AND (Day(dt)=DAY (@ct))
set @n=@n+1
end
go 展开
2个回答
展开全部
CREATE PROCEDURE [test]
as
Declare @n int
Declare @ct datetime
set @n=-30
while @n<0
begin
set @ct=DATEADD(DAY,@n, GETDATE())
INSERT INTO AI
SELECT AVG (f1) AS f1, AVG (f2) AS f2, AVG (f3) AS f3, @ct AS dt
FROM demo
WHERE YEAR(dt)=YEAR(@ct) AND Month(dt)=MONTH(@ct) AND Day(dt)=DAY (@ct)
set @n=@n+1
end
go
as
Declare @n int
Declare @ct datetime
set @n=-30
while @n<0
begin
set @ct=DATEADD(DAY,@n, GETDATE())
INSERT INTO AI
SELECT AVG (f1) AS f1, AVG (f2) AS f2, AVG (f3) AS f3, @ct AS dt
FROM demo
WHERE YEAR(dt)=YEAR(@ct) AND Month(dt)=MONTH(@ct) AND Day(dt)=DAY (@ct)
set @n=@n+1
end
go
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询