SqlServer2008R2基础知识

时间:2023-02-02 12:17:57

1.查看sqlServer事务隔离基本

dbcc useroptions;

2.设置事务的隔离级别

set transaction isolation level read uncommitted;

3.查看锁视图

select request_session_id,
resource_type,
request_status,
request_mode,
resource_description,
object_name(p.object_id) as object_name,
p.index_id
from sys.dm_tran_locks
left join sys.partitions p
on sys.dm_tran_locks.resource_associated_entity_id = p.hobt_id;

4.格林威治时间 转换为北京时间(北京时间=GMT时间+8小时)

例如:2016-06-08T08:11:35

转换后:2016-06-08 16:11:35.000

select switchoffset('2016-06-08T08:11:35', '+08:00');

5.查询数据库的连接数

(1).查看当前数据库设置的最大连接
select @@max_connections;
(2).查看sqlserver当前的连接数
select loginame,count(1) as Nums FROM sys.sysprocesses GROUP by loginame ORDER by 2 desc;