批量插入更新的 sql语句
2011-12-18 22:01
453 查看
--备份一个表中得数据到另外一张表 (表不存在)
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
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
相关文章推荐
- mybatis--mysql 批量插入批量更新在一条sql语句中完成
- 在MySQL命令行窗口执行sql脚本,批量执行SQL语句,批量更新数据
- Sql语句批量更新数据(多表关联)
- SQL 批量更新语句
- 记一次上万条数据的正确插入更新sql语句
- 批量更新sql 语句
- mysql如何用一条sql语句实现不存在就插入,存在的话则更新
- mysql批量插入,更新的sql语句
- SQL-批量插入和批量更新
- 批量数据插入的SQL语句
- Mysql 一条SQL语句实现批量更新数据,update结合case、when和then的使用案例
- Mysql 一条SQL语句实现批量更新数据,update结合case、when和then的使用案例
- 利用游标循环进行更新插入的SQL事务语句
- 分享高性能批量插入和批量删除sql语句写法
- 利用游标循环进行更新插入的SQL事务语句
- Mysql--一条SQL语句多条插入、更新、删除
- 【批量生成10万条sql数据库数据+IO流的使用】生成简单sql插入语句大量数据,以及输出流生成文件2017年
- 关于mybatis中批量插入和批量查询的sql语句查询
- Go sqlx包 + postges pq包实现postgres的批量插入、更新
- 一条insert语句批量插入多条记录 AND 多条件游标更新 变CASE WHEN更新法提高速度