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

SQl SERVER 2000 遍历表中数据的方法

方法一:使用游标
declare @ProductName nvarchar(50)
declare pcurr cursor for select ProductName from Products
open pcurr
fetch next from pcurr into @ProductName
while (@@fetch_status = 0)
begin
print (@ProductName)
fetch next from pcurr into @ProductName
end
close pcurr
deallocate pcurr
此方法适用所有情况,对标结构没有特殊要求。
方法二:使用循环
declare @ProductName nvarchar(50)
declare @ProductID int
select @ProductID=min(ProductID) from Products
while @ProductID is not null
begin
select @ProductName=ProductName from Products where
ProductID=@ProductID
print(@ProductName);
select @ProductID=min(ProductID) from Products where
ProductID>@ProductID
end
此方法适用于表带有自动增加标识的字段


相关文档:

sql索引类型

索引类型
唯一索引:唯一索引不允许两行具有相同的索引值
主键索引:为表定义一个主键将自动创建主键索引,主键索引是唯一索引的特殊类型。主键索引要求主键中的每个值是唯一的,并且不能为空
聚集索引(Clustered):表中各行的物理顺序与键值的逻辑(索引)顺序相同,每个表只能有一个
非聚集索引(Non-clustered):非聚 ......

sql语句基础

--sql structured query language
--DML--Data Manipulation Language--数据操作语言
query information (SELECT),
add new rows (INSERT),
modify existing rows (UPDATE),
delete existing rows (DELETE),
perform a conditional update or insert operation (MERGE),
see an execution plan of SQL (EXPLA ......

SQL 2K 数据类型 (转)

(转载)SQL 2K 数据类型 
(1)char、varchar、text和nchar、nvarchar、ntext
char和varchar的长度都在1到8000之间,它们的区别在于char是定长字符数据,而varchar是变长字符数据。所谓定长就是长度固定的,当输入的数据长度没有达到指定的长度时将自动以英文空格在其后面填充,使长度达到相应的长度;而变长字符数据 ......

sql数据库置疑解决办法

注'svw'为出问题的数据库,此方式对sql7.0以上版本有效,其它低版本为测试
sp_configure  'allow',1 
go
reconfigure  with  override 
go
update  sysdatabases  set  status=32768  where  name='svw' 
go
dbcc  rebuild_log('svw','D:\mssql7\data ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号