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…
SELECT B.NAME,A.ROW_COUNT FROM SYS.DM_DB_PARTITION_STATS A,SYS.OBJECTS BWHERE A.OBJECT_ID=B.OBJECT_ID AND A.INDEX_ID<=1AND B.TYPE='U'AND A.ROW_COUNT>8000 ORDER BY ROW_COUNT DESC…
大家都知数据库表中的列可以自增长,但是有时候我们需要插入数据的时候会指定这一列的数据. 这时候我们可以很简单的利用sql语句来执行新增一条的数据,如下: set IDENTITY_INSER 表名 on insert into 表名(列1,列2,...)values (值1,值2,...); 当然咯,不能忘记还原这一列的自增长啊 Set IDENTITY_INSERT 表名 OFF 我们大家都只知道,批量插入语句有一条比较简单的SQL insert into 表1 select 列1,列2,..…
DECLARE @what varchar(800) SET @what='lll' --要搜索的字符串 DECLARE @sql varchar(8000) DECLARE TableCursor CURSOR LOCAL FOR SELECT sql='IF EXISTS ( SELECT 1 FROM ['+o.name+'] WHERE ['+c.name+'] LIKE ''%'+@what+'%'' ) PRINT ''所在的表及字段:['+o.name+'].['+c.name+'…
delete from TABLEA A where A.FIELD1=10 (ORACLE适用)delete TABLEA from TABLEA A where A.FIELD1=10 (SQLSERVER适用)delete from TABLEA where TABLEA.FIELD1=10 (Ora/SQL均适用)…
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…