本人刚学SQL,实在看不懂了,请高手指点呀.
sjyzx 2006-07-26 08:58:15 use factory
go
set nocount on
-- 声明变量
declare @no int,@name char(10)
--声明游标
declare w_cursor cursor
for select 职工号,姓名
from worker
where 职工号 in
(select 职工号
from salary
group by 职工号
having avg(工资)<(select avg(工资) from salary))
--打开游标
open w_cursor
--提取每一行数据
fetch next from w_cursor into @no,@name
--打印表标题
print '职工号 姓名'
print '---------'
while @@fetch_status= 0
begin
--打印一行数据
print cast(@no as char(8))+@name
--提取下一行数据
fetch next from w_cursor into @no,@name
end
--关闭游标
close w_cursor
--释放游标
DEALLOCATE w_cursor
go
服务器: 消息 170,级别 15,状态 1,行 27
第 27 行: ' ' 附近有语法错误。
本人刚学SQL,实在看不懂了,请高手指点呀.