SQL Server T-SQL高级查询 高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student; //查询student表中所有字段.   --all 查询所有 select all sex from student;   --distinct 过滤重复 select distinct sex from student;   --count 统计 select count(*) from student; selec…
--select select * from student; --all 查询所有 select all sex from student; --distinct 过滤重复 select distinct sex from student; --count 统计 select count(*) from student; select count(sex) from student; select count(distinct sex) from student; --top 取前N条记录 s…
name like 'ja%'; select * from student where name not like '%[j,n]%'; select * from student where name like '%[j,n,a]%'; select * from student where name like '%[^ja,as,on]%'; select * from student where name like '%[ja_on]%'; --in 子查询 , ); --not in…
高级查询在数据库中用得是最频繁的,也是应用最广泛的.   Ø 基本常用查询   --select select * from student; --all 查询所有 select all sex from student; --distinct 过滤重复 select distinct sex from student; --count 统计 select count(*) from student; select count(sex) from student; select count(di…
高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student;   --all 查询所有 select all sex from student;   --distinct 过滤重复 select distinct sex from student;   --count 统计 select count(*) from student; select count(sex) from student; select count(…
高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student;   --all 查询所有 select all sex from student;   --distinct 过滤重复 select distinct sex from student;   --count 统计 select count(*) from student; select count(sex) from student; select count(…
21.SQL运行Log的读取 .EXEC xp_readerrorlog 0,1,null,null,'开始时间','结束时间' 22. Alwayson 状况及传输情况监控 SELECT ar.replica_server_name AS [副本名称] , ar.availability_mode_desc as [同步模式], DB_NAME(dbr.database_id) AS [数据库名称] , dbr.database_state_desc AS [数据库状态], dbr.synch…
9. 查询备份还原数据库的进度. select command ,percent_complete ,est_time_to_go=convert(varchar,(estimated_completion_time/3600000))+' hour, ' +convert(varchar,(estimated_completion_time)/60000)+' min, ' +convert(varchar,(estimated_completion_time)/1000)+' sec' ,s…
1. 查询某存储过程的访问情况 SELECT TOP 1000 db_name(d.database_id) as DBName, s.name as 存储名字, s.type_desc as 存储类型, d.cached_time as SP添加到缓存的时间, d.last_execution_time AS 上次执行SP的时间, d.last_elapsed_time as [上次执行SP所用的时间(微秒)], d.total_elapsed_time [完成此SP的执行所用的总时间(微秒)…
假设当前是第PageNo页,每页有PageSize条记录,现在分别用Mysql.Oracle和SQL Server分页查询student表. 1.Mysql的分页查询: SELECT * FROM student LIMIT (PageNo ) * PageSize,PageSize; 理解:(Limit n,m)  =>从第n行开始取m条记录,n从0开始算. 2.Oracel的分页查询: SELECT * FROM ( SELECT ROWNUM rn ,* FROM student WHER…