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,实在看不懂了,请高手指点呀.
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,实在看不懂了,请高手指点呀.
解决方案 »
- 未能查询SQL Server 中的数据库名称的列表
- update数据时出错
- 求一个sql语句
- 我用sqlserver2008R2版新建表时出现“服务器未能装载DCOM” 7404错误怎么解决
- sql语句中and和between and能在一块用吗
- 服务器无法读取文件 C:\WINNT\help\iisHelp\common\404b.htm。该文件不存在。
- SQL 怎么对查询对果的进行拼接??
- 刚才的贴还有问题,再送100分好了
- 为什么现在我的登录账号没有管理权限了?
- 菜鸟问题,求一个表中(有时间字段)最小时间的那条记录,用SQL怎么写??
- 数据统计问题....请高手进!!
- 如何根据某个字段名,查到它在哪个表里?
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--Check the difference betwwen ' ' and ' '
(select 职工号 from salary group by 职工号
这里都有空行,唉,我还是看不懂呀,能不能说明白一点或