SQL语句练习实例之七 剔除不需要的记录行


复制代码 代码如下:

--相信大家肯定经常会把数据导入到数据库中,但是可能会有些记录行的所有列的数据是null,这为null的数据是我们不需要
--现在需要一个简单的查询来剔除掉这些为null的记录行。
--假设表名为 emplyees
--方法1.
---先把数据导入到数据库
---其次:
select * from sys.columns
where object_id =(select object_id from sys.objects where name='EMPLYEEs')

---方法2
---使用数据库提供的函数
exec sp_columns 'Employees'
delete from Employees where coalesce(status,tel,gwei,ADDRESS1,address2,nwei) is null

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3