易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

SQL 自增列(非自增字段)

--
> 测试数据:[tb]
if

object_id
(
'
[tb]
'
)
is

not

null

drop

table

[
tb
]
go

create

table

[
tb
]
(
[
id
]

int
,
[
lx
]

int
)
insert

[
tb
]
select

29
,
2

union

all
select

30
,
3

union

all
sel ......

SQL 学习笔记 自连接

自连接是指一个表与其自身进行连接。
举一个简单的实例,一个学生课程成绩表StudentScore,其中包括学生编号/studentid,所选课程/coursename,课程成绩/score
选择每门课程的前两名学生,并将他信息输出出来
此时你的第一反应就是要把学生按所选课程进行分组,然后比较获得每门课程里面前两位的学生
分组的方式有group b ......

【转】+【原】SQL Server 日期函数:某天是星期几

要得到某一天是星期几,需要用到 SQL Server 中的日期函数:datename()。 今天是星期几,例子 1: 1: set language N'English'
2: select datename(weekday, getdate())
3: 
4: Wednesday
今天是星期几,例子 2:

1: set language N'Simplified Chinese'
......

测试人员要掌握的基本的SQL语句(上)

测试人员要掌握的基本的SQL语句(上)
 
 
 
 
                                        ......

SQL Server之分布式事务

SQL Server之分布式事务
 
 收藏
--> Title  : SQL Server之分布式事务
 
--> Author : wufeng4552
 
--> Date   : 2009-11-11
 
SQL Server之分布式事务
 
(一)概念:
 
分布式事务是涉及来自两个或多个源的资源的事务。Microsoft® SQL Serv ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号