打你一下

sql server

select *,RANK() OVER(PARTITION BY SEX ORDER BY ProfitAmount)
AS RANK FROM UserInfo
(1,1,1,2)
select *,DENS_RANK() OVER(PARTITION BY SEX ORDER BY
ProfitAmount) AS RANK FROM UserInfo
(1,1,1,4)

set statistics io on
go
select * from userinfo where username='lsf1'(查询数据条的问题)

dbcc traceon (1222,1204,3605,-1)(记录死锁到日志)

18032819668
删除重复记录
delete from Rebate_Logs where id not in (select max(id) from
Rebate_Logs group by usercode_sk,ordercode)

查询锁表
declare @spid ?int
Set @spid ?= 60
declare @sql varchar(1000)
set @sql='kill '+cast(@spid ?as varchar)
exec(@sql)
select???
request_session_id???spid,OBJECT_NAME
(resource_associated_entity_id)?tableName???
from???
sys.dm_tran_locks?where?resource_type='OBJECT'

递归查出所有的下级
with cte (usercode,parentcode,username)
as (
select usercode,parentcode,username from useragent where
parentcode='DL000320'
union all
select t.usercode,t.parentcode,t.username from useragent as t
inner join cte as c on t.parentcode=c.usercode
)
select usercode,parentcode,username from cte

posted on 2018-03-06 14:43  打你一下  阅读(242)  评论(0编辑  收藏  举报

导航