易截截图软件、单文件、免安装、纯绿色、仅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 ......

Access与Sql Server之ASP代码比较

后台数据库:
[Microsoft Access]

[Microsoft Sql Server]
更换之后,ASP代码应注意要修改的一些地方:
[一]连接问题(举例)
[Microsoft Access]
constr = "DBQ=c:\data\clwz.mdb; DRIVER={Microsoft Access Driver (*.mdb)}"
[Microsoft Sql Server]
constr = "DRIVER={SQL Server};SERVER=host;DATA ......

DB2 SQL性能优化相关的10大要素

下面提出了10条和DB2 SQL性能相关的10条因素:
1、提供适当的统计信息
对DB2优化管理器(otimizer)而言,如何更加有效的执行SQL语句是由存在于DB2 catalog中的统计信息决定的,优化器利用这些信息决定最优化的路径。
因此,为了保持系统能够做出最佳选择,需要经常的运行Runstats命令,来保持系统统计信息的及时有效。 ......

sql重复数据处理,有唯一ID,formid有重复,留一条

/*sql重复数据处理,有唯一ID,formid有重复*/
/*查出重复的fromid*/
select formid from GaiaSaver_BUG group by formid having count(*)>1
/*删除重复formid,只留一条*/
delete from GaiaSaver_BUG  where ID not in
(select   min(ID) as ID  from  GaiaSaver_BUG  group by for ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号