SQL Server 一些操作语句

删表 -------drop table s_task
删表中所有的数据----------truncate table tablename
根据条件删表中的数据 -----delete from tablename where 条件
去重 ---- distinct 字段
select distinct userclass from s_tablelist -- or - - select userclass from s_tablelist group by userclass having COUNT(userclass)>0 {select * from s_tablelist where userclass in (...)}

插入数据
insert into tablename(...字段名...)
select ...对应的值...

可用union 连接多条要插入的数据

如:

insert into Student(S_StuNo,S_Name,S_Sex,S_Height)
select '003','博客','M','178' union 
select '005','作者','F','175'

猜你喜欢

转载自www.cnblogs.com/zzy567/p/9151432.html