SELECT top 1000 j.name AS [作业名], h.step_id AS 步骤Id, h.step_name AS 步骤名称 , h.message AS [作业消息] , h.run_date AS [运行日期] , h.run_time AS [运行时间] , msdb.dbo.agent_datetime(h.run_date, h.run_time) AS '作业开始运行时间' , CAST(run_duration / 10000 AS VARCHAR(2)) + N'小时' + CAST(( run_duration - run_duration / 10000 * 10000 ) / 100 AS VARCHAR(2)) + N'分钟' + SUBSTRING(CAST(run_duration AS VARCHAR(10)), LEN(CAST(run_duration AS VARCHAR(10))) - 1, 2) + N'秒' AS [运行耗时] FROM msdb.dbo.sysjobhistory h LEFT JOIN msdb.dbo.sysjobs j ON h.job_id = j.job_id WHERE --- j.name ='作业名称' and 作业名称 ---Run_Date = CAST(CONVERT(VARCHAR(8), GETDATE(), 112) AS INT) --今天执行的作业 ---AND h.run_status = 1 --执行成功 ORDER BY h.run_date desc
月度归档:2017年04月
MSSQL server nolock readpast 简介
一、nolock readpast 功能简介
nolock readpast的功能是:当数据表被其它资源锁定时,查询语句还可以继续向下运行。
二、nolock 与 readpast 区别
nolock 可将未提交事务(commit tran)的数据展示出来
readpast 会将未提交事务的数据隐藏起来
例:
当我们使用
select * from 表名(nolock) 返回结果中,可以返回被锁定的数据
select * from 表名(readpast) 返回结构中 不包含被锁定的数据
三、nolock、readpast举例使用
测试读取数据
3.1 分别打开查询分析器-两个窗口
3.2 在第一个窗口中运行脚本
CREATE TABLE tableTest (keyId int IDENTITY(1,1), infoTest varchar(60)) go insert tableTest(infoTest) values('test1') go BEGIN TRANSACTION insert tableTest(infoTest) values('test2')
3.3 在第二个窗口中运行以下脚本 结果如下图所示:
select * from tableTest(nolocK) select * from tableTest(readPast)
相关阅读:
sp_lock 说明
检测系统MSSQL中处于事务中的对象
c# 序列化
序列化 反序列化简介
c#序列化又称为串行化,她的主要功能是将一个对象转换为二进制流,并将对象保存到文件或数据库中,主要目的是将对象持久化的存储到某一个地方或将对象从一个位置传送到另一个位置。
c#反序列化,她的主要功能是将序列化的文件还原为对象,供系统其它地方使用。
c#提供三种串行化的方式:
1.1 BinaryFormatter
采用二进制数据流的方式进行序列化
1.2 SoapFormatter
将数据流格式化为XML存储 和传输
1.3 XmlSerializer
将数据流转换为XML存储和传输
二、序列化 反序列化 应用
2.1 BinaryFormatter
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; using System.Runtime.Serialization.Formatters.Binary; //// ﹤summary﹥ /// 定义一个实体类 /// ﹤/summary﹥ [Serializable] //加上此属性 表示此类可进行序列化 public class classTest { public int keyId= 1; public string name = "nameTest"; [NonSerialized] //表示此字段不可进行序列化 public string value = "value"; } 下面是串行化和反串行化的方法: 复制代码代码如下: //对一个实体类 系列化 public void xiLieHua() { classTest test = new classTest(); FileStream fileTest = new FileStream("c:\\test.dat", FileMode.Create); BinaryFormatter b = new BinaryFormatter(); b.Serialize(fileTest, test); fileStream.Close(); } //对一个文件 反系列化 public void fanXiLieHua() { classTest c = new classTest(); c.value = "valueTest"; FileStream fileStream = new FileStream("c:\\test.dat", FileMode.Open, FileAccess.Read, FileShare.Read); BinaryFormatter b = new BinaryFormatter(); c = b.Deserialize(fileStream) as classTest; Response.Write(c.KeyId); Response.Write(c.value); fileStream.Close(); }
2.2 SoapFormatter序列化
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; using System.Runtime.Serialization.Formatters.Soap; //// ﹤summary﹥ /// 定义一个实体类 /// ﹤/summary﹥ [Serializable] //加上此属性 表示此类可进行序列化 public class classTest { public int keyId= 1; public string name = "nameTest"; [NonSerialized] //表示此字段不可进行序列化 public string value = "value"; } 下面是串行化和反串行化的方法: 复制代码代码如下: //对一个实体类 系列化 public void xiLieHua() { classTest test = new classTest(); FileStream fileTest = new FileStream("c:\\test.dat", FileMode.Create); SoapFormatter b = new SoapFormatter(); b.Serialize(fileTest, test); fileStream.Close(); } //对一个文件 反系列化 public void fanXiLieHua() { classTest c = new classTest(); c.value = "valueTest"; FileStream fileStream = new FileStream("c:\\test.dat", FileMode.Open, FileAccess.Read, FileShare.Read); SoapFormatter b = new SoapFormatter(); c = b.Deserialize(fileStream) as classTest; Response.Write(c.KeyId); Response.Write(c.value); fileStream.Close(); }
2.3 XmlSerializer
在xml序列化中
当一个字段在序列化时,需要被忽略,此时我们需要使用XmlIgnore属性,她的行为等价于NoSerialized。
[Serializable] public class test { public string testName; [XmlIgnore] public string testValue; public test2(string testName, string testValue) { test = test; testValue = testValue; } } C#序列化和反序列化方法: 复制代码代码如下: public void XMLSerializetest() { test c = new test("name1","nameValue"); XmlSerializer xmlInfo = new XmlSerializer(typeof(test)); Stream stream = new FileStream("c:\\testXml.XML",FileMode.Create,FileAccess.Write,FileShare.Read); xmlInfo.Serialize(stream,c); stream.Close(); } public void XMLDeserializeTest() { XmlSerializer xs = new XmlSerializer(typeof(Person)); Stream stream = new FileStream("C:\\testXml.XML",FileMode.Open,FileAccess.Read,FileShare.Read); test test = xs.Deserialize(stream) as test; Response.Write(test.testName); Response.Write(test.testValue.ToString()); stream.Close(); }
相关阅读:
c# 序列化与反序列化