mssql sqlserver delete关键字简介


摘要:
下文讲述 sqlserver delete 关键字从表中删除数据的用法


delete 语法简介:
—-删除指定条件的行数
delete from [表名]
where 限定条件

—-限定最多删除的行数
set rowcount 1
delete from [表名]
where 限定条件
例:

   create table A(keyIdA int identity,nameA varchar(100),name2A varchar(100))
 go
/*生成数据*/
insert into A (nameA,name2A)values('A1','A11'),('A2','A22'),('A3','A33')
 go
delete from A  where keyIdA =2 
--------------------------------
select * from A 
go

set rowcount 1 ----设定影响的行数 然后执行删除操作 
delete from A  
go
 select * from A 
go
truncate table A
drop table A 
 
mssql_sqlserver_delete删除数据的两种方法分享

mssql_sqlserver_delete删除数据的两种方法分享