潇潇洒洒

 

批量插入更新的 sql语句

--备份一个表中得数据到另外一张表 (表不存在)

select * into [Northwind].[dbo].abc
FROM [Northwind].[dbo].[Categories]

--批量插入(表存在)

insert into [Northwind].[dbo].abc
(CategoryName,[Description],Picture)
select CategoryName,[Description],Picture FROM [Northwind].[dbo].[Categories]

--批量更新
update [Northwind].[dbo].abc
set abc.CategoryName = LEFT( [Categories].CategoryName,10)
from [Northwind].[dbo].[Categories]
where abc.CategoryID = [Categories].CategoryID

--删除
delete from [Northwind].[dbo].abc
where abc.CategoryID in (select CategoryID from [Categories] )

--删除表
drop table [Northwind].[dbo].abc

posted on 2011-12-18 22:01  肖磊  阅读(699)  评论(0编辑  收藏  举报

导航