--表数据查询----数据的基本查询-- --数据简单的查询--select * | 字段名[,字段名2, ...] from 数据表名 [where 条件表达式] 例: use 商品管理数据库 go select * from 商品信息表 select 商品编号,商品名称,产地 from 商品信息表 selelct * from 商品信息表 where 产地='辽宁沈阳' 理解例子 --关键字辅助查询-- --1)distinct关键字 (用来消除查询结果中的重复行,使用时紧跟在select命
) Drop Procedure GenerateData go CREATE PROCEDURE GenerateData @tablename sysname AS begin ) ) ) declare @xtype tinyint declare @name sysname declare @objectId int declare @objectname sysname declare @ident int set nocount on set @objectId=object_id(
1.获取某张表在哪些存储过程中使用到 select distinct object_name(id) from syscomments where id in (select object_id from sys.objects where type ='P') and text like'%tableName%' 2.获取某张表的创建时间 select * from sys.tables where name ='tableName ' order by create_date desc 3.
表结构 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名, ( then '√'else '' end) 标识, (case when (SELECT count(*) FROM sysobjects WHERE (name in (SELECT name FROM sysindexes WHERE (id = a.id) AND (indid in (SELECT indid FROM sysindexkeys WHERE (i
update wset w.TagCount=x.TagCountfrom (select ItemID,COUNT(*) as TagCount from r where IsValid=1 group by ItemID) as xwhere ID =4 and IsValid=1 and w.ID=x.ItemID
查看SqlServer 数据库中各个表多少行 : SELECT A.NAME ,B.ROWS FROM sysobjects A JOIN sysindexes B ON A.id = B.id WHERE A.xtype = 'U' AND B.indid IN(0,1) ORDER BY B.ROWS DESC 数据库磁盘占用量: select name, CAST(convert(float,size) * (8192.0/1024.0)/1024 AS nvarchar)+'MB' AS
SQL Server获取指定行(如第二行)的数据 --SQL Server获取指定行(如第二行)的数据-- --法一(对象法)-- select * from ( select * , number = row_number() over(order by Grade desc) from Students ) m where number = 2 --法二(排除法)--- select top 1 * from Students where Grade not in ( select