mssql row_number() partition 使用方法理解
Sql2005中使用ow_number() partition进行分组实验,
SQL:
select * from stu
select id,row_number() over (partition by snm order by id) from stu
结果:
id snm
----------------
111 111V
111 111W
222 222N
333 3123
444 3123
555 3123
666 3232
777 3232
--分组后的结果
id
------------
111 1
111 1
222 1
333 1
444 2
555 3
666 1
777 2
可以注意到分组和特殊标记的结果如上面所示
相关文档:
今天在聊天系统中需要系统执行一个多层嵌套查询。
一开始语句如下总出现错误:原来是在]='123') 后我多加了一个 as tb1
改为如下后,正确运行。
select * from ( select top(10) * from ( select top(100) * from (select [chatcontent].[senderid],[chatcontent].[id] ,[chatcontent].[toid] ,[chatc ......
从mssql6.5开始,微软提供了两个不公开,非常有用的系统存储过程sp_MSforeachtable和sp_MSforeachdb,用于遍历某个数据库的每个表和遍历DBMS管理下的每个数据库。
我们在master数据库里执行下面的语句可以看到两个proc详细的代码
use master
exec sp_helptext sp_MSforeachtable
exec sp_helptext sp_Msforeachdb
sp_M ......
select语句前加:
declare @d datetime
set @d=getdate()
并在select语句后加:
select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
转自:动态网制作指南 www.knowsky.com
这是简易的查看执行时间的方法。
===========================================(一下内容转自:CSDN)
MSSQL Server中通过查 ......
--字段添加说明
EXEC sp_addextendedproperty 'MS_Description', '要添加的说明', 'user', dbo, 'table', 表名, 'column', 列名
--删除字段说明
EXEC sp_dropextendedproperty 'MS_Description', 'user', dbo, 'table', 表名, 'column', 字段名
--查看字段说明
SELECT
[Table Name] = i_s.TAB ......
How is MSSQL using memory?
http://www.sqlhacks.com/Administration/Memory-Usage
Memory is one the most important factor affecting MSSQL performance.
As an administrator, you should be monitoring the memory
regularly. When Microsoft SQL Server runs out of memory, it will use
virtual memory: ie: ......