sql 游标的使用
一个例子:从tszl表中查出数据,根据cs字段的值决定往BOOK_SERIAL表中插入几行数据。
declare @num int
declare @id varchar(60)
declare @classbm varchar(60)
set @classBm='101'
declare id cursor for select id,cs from [tszl]
open id
fetch next from id into @id,@num
while @@fetch_status!=-1
begin
while(@num>0)
begin
set @num = @num-1
INSERT INTO [BOOK_SERIAL]
([id]
,[classBm]
,[state])
values(@id,@classBm,'0')
end
fetch next from id into @id,@num
end
close id
相关文档:
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select
CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100),
GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3):
16/05/06
Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06
Select
CON ......
我们要建立多级关系,首先需要两个表.
第一个表表示直属结构,比如说我们公司有一个部门。而这个部门下还有3个小组,那么3个小组属于这个部门.第二个表表示多层结构,就象第一表里面所表示的,这三个小组同时还属于公司.而这个公司同时属于这3个小组的父级的父级的部门。假如我 ......
-- 一: 处理未查到的空值
select
case when exists(select EndPrice from T_stock where BOMSN='0109')
then (select EndPrice from T_stock where BOMSN='0109')
else 0 end
--二:更新字段值
--strNum 数量
--strId 序号
update T_buy_Pro set Co ......
测试人员要掌握的基本的SQL语句(上)
  ......