SQL Server查询结果插入表】的更多相关文章

a) 插入新表 select * into newtable from table b) 插入已经存在的表 insert into table select * from table2 where...…
sql server在执行查询语句时会锁表.在锁表期间禁止增删改操作. 如果不想锁表,那就再表名或别名后面加上WITH(NOLOCK) 如下所示:…
SELECT 表名 then d.name else '' end, 表说明 then isnull(f.value,'') else '' end, 字段序号=a.colorder, 字段名=a.name, 标识 then '√'else '' end, 主键 FROM sysobjects where xtype='PK' and name in ( SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexk…
一.查询数据库(sys.databases —— select *from sys.databases where name='<数据库名>') select *from sys.databases where name='MyDatabase' 二.查询表(sysobjects —— select *from sysobjects where id=OBJECT_ID('<表名>')) select *from sysobjects where id=OBJECT_ID('Stu…
;with cte as ( select * from Associator where No = 'mc1007' union all select air.* from Associator as air inner join cte on air.ParentNo = cte.No ) select * from cte;…
)) DECLARE @str VARCHAR(MAX) ,) ,@start INT ,@end INT ,) SET @str = '1,2,3,4,5,6,7,8' SET @split = ',' ) BEGIN SET @end = CHARINDEX(@split, @str, @start + LEN(@split)) BEGIN , LEN(@str) - @START) END ELSE BEGIN , ) END SET @start = @end INSERT INTO @…
select object_name(id) tablename, 8*reserved/1024 reserved, rtrim(8*dpages)+'kb' used, 8*(reserved-dpages)/1024 unused, 8*dpages/1024-rows/1024*minlen/1024 free, rows --,* from sysindexes where indid=1 order by tablename,reserved desc…
select name from sysobjects where xtype='u' order by name…
SELECT a.name, b.rows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id WHERE ( a.type = 'u' )  AND ( b.indid IN ( 0, 1 )) ORDER BY a.name, b.rows DESC…
SELECT obj.name tablename, CAST ( CASE WHEN (SELECT COUNT() FROM sys.indexes WHERE object_id= obj.OBJECT_ID AND is_primary_key=) >= THEN ELSE END AS BIT) HasPrimaryKey from 数据库名.sys.objects obj where type='U' or type='V' order by obj.name…