查询表名为tb_menu的所有列名 select name from syscolumns where id=object_id('tb_menu') 查询表名为tb_menu的所有列名个数 select count(name) from syscolumns where id=object_id('tb_menu') 或者 select count(syscolumns.name) from syscolumns ,sysobjects where syscolum
SQL 查询表中31到40的记录,考虑id不连续的情况 写出一条sql语句输出users表中31到40记录(数据库为SQL Server,以自动增长的ID作为主键,注意ID可能不是连续的)? --使用not in select top 10 * from users where id not in(select top 30 id from users order by id asc) order by id asc --使用order by select * from (select to
SELECT 索引名称=a.name ,表名=c.name ,索引字段名=d.name ,索引字段位置=d.colid ? 1 2 3 4 5 6 7 8 FROM sysindexes a JOIN sysindexkeys b ON a.id=b.id AND a.indid=b.indid JOIN sysobjects c ON b.id=c.id JOIN syscolumns d ON b.id=d.id AND b.colid=d.colid
--name 字段名称--user_type_id --max_length 最大长度--is_nullable 是否允许空--remark 描述SELECT c.name, c.user_type_id, c.max_length, c.is_nullable, remark = ex.value FROM sys.columns c inner JOIN sys.extended_properties ex ON ex.major_id = c.object_id AN
----查询所有的表 SELECT * FROM SYSOBJECTS WHERE TYPE='U' ----根据表名查询所有的字段名及其注释 SELECT A.NAME,B.VALUE FROM SYSCOLUMNS A LEFT JOIN SYS.EXTENDED_PROPERTIES B ON A.ID=B.MAJOR_ID AND A.COLID=B.MINOR_ID INNER JOIN SYSOBJECTS C ON A.ID=C.ID AND UPPER(C.NAME)='tb_n
1.获取主键信息 EXEC sp_pkeys @table_name='{0}' 2.获取外键 方法二 SELECT Field=(SELECT name FROM syscolumns WHERE colid=b.fkey AND id=b.fkeyid) , FKTable=object_name(b.rkeyid), FKKeyField=(SELECT name FROM syscolumns WHERE colid=b.rkey AND id=b.rkeyid) FROM sysobj
SELECT [Table Name] = OBJECT_NAME(c.object_id), [Column Name] = c.name, [Description] = ex.value FROM sys.columns c LEFT OUTER JOIN sys.extended_properties ex ON ex.major_id = c.object_id AND ex.minor_id = c.column_id AND ex.name = 'MS_Description' W
原文地址:https://blog.csdn.net/changhong009/article/details/29587063 --快速查看表结构(比较全面的) SELECT CASE WHEN col.colorder = 1 THEN obj.name ELSE '' END AS 表名, col.colorder AS 序号 , col.name AS 列名 , ISNULL(ep.[value], '') AS 列说明 , t.name AS 数据类型 , col.length AS
IF OBJECT_ID('tempdb..#TB_TEMP_SPACE') IS NOT NULL DROP TABLE #TB_TEMP_SPACE GO CREATE TABLE #TB_TEMP_SPACE( NAME ) ,ROWS INT ,RESERVED ) ,DATA ) ,INDEX_SIZE ) ,UNUSED ) ) GO SP_MSFOREACHTABLE 'INSERT INTO #TB_TEMP_SPACE exec sp_spaceused ''?''' GO S
数据库相关知识积累(sqlserver.oracle.mysql) 1. sqlserver :断开所有连接: (还原数据库) 1.数据库 分离 2. USE master GO ALTER DATABASE [GPOSDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO --查看是否还有用户连接 SELECT * FROM sys.[sysprocesses] WHERE DB_NAME([dbid])='gposdb' GO ALTER DATABA
sqlserver查询表索引 2012-09-19 18:18 by Spring.Guo, 4599 阅读, 0 评论, 收藏, 编辑 SELECT 索引名称=a.name ,表名=c.name ,索引字段名=d.name ,索引字段位置=d.colid FROM sysindexes a JOIN sysindexkeys b ON a.id=b.id AND a.indid=b.indid JOIN sysobjects c ON
SQLServer中查询表结构(表主键 .列说明.列数据类型.所有表名)的Sql语句 1.查询数据库中的所有表名称: SELECT name FROM SysObjects Where XType='U' ORDER BY Name 结果: 2.查询数据库中指定表的表结构: --快速查看表结构 THEN obj.name ELSE '' END AS 表名, col.colorder AS 序号 , col.name AS 列名 , ISNULL(ep.[value], '') AS 列说明 ,