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个回答
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
展开全部
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询