sql语句

在SQL里,我们常用到复制表来完成一些功能。
 
SQL复制表的几种方法:
 
SQL复制整张表
select * into NewTableName from OldTableName
 
复制列名而不要内容
select * into NewTableName from OldTableName where 1=0
 
表间数据复制
insert into Table1(zt) select titile from Table2
 
==========================

用SQL语句更改自动编号的字段重新从'1'开始编号

tableName(id,clcode,cloth) id字段为identity(int,1,1) 重建id
select * into #aa from tableName
truncate table tableName
dbcc checkident(tableName,reseed,0)
set IDENTITY_INSERT ON
insert tableName(clcode,clname) select clcode,clname from #aa
//注意不能选择id列
drop table #aa
==========================

SQL 数据库 'tempdb' 的日志已满的解决办法 ---SQL解决代码方法

use tempdb

select * from tempdb.dbo.sysfiles

dump transaction tempdb with no_log

dbcc shrinkfile ('templog',1)

select * from tempdb.dbo.sysfiles

posted @ 2012-09-05 16:24  祺祺怪怪的  阅读(191)  评论(0编辑  收藏  举报