Sqlserver中存储过程和游标的一些使用例子

/*带输入输出参数存储过程*/ALTER PROCEDURE pro_test2 @userID INT, @maxUserID INT OUTPUT, @countUser INT OUTPUTAS BEGIN SELECT * FROM dbo.SY_ADMIN WHERE UserID=@userID --10075 SELECT @maxUser …… 阅读全文

使用WITH AS提高性能简化嵌套SQL

一.WITH AS的含义 WITH AS短语,也叫做子查询部分(subquery factoring),可以让你做很多事情,定义一个SQL片断,该SQL片断会被整个SQL语句所用到。有的时候,是为了让SQL语句的可读性更高些,也有可能是在UNION ALL的不同部分,作为提供数据的部分。 特别对于UNION ALL比较有用。因为UNION ALL的每个部分可能相同,但是如果每个部分 …… 阅读全文

sqlDependency监控数据库数据变化,自动通知

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Configuration;using System.Data.SqlClient;using System.Data;namespa …… 阅读全文

asp.net mvc5中使用缓存依赖SqlCacheDependency

缓存是用来提高应用性能,降低服务器压力。适用于数据不易变,数据易通用的情景, 对于动态查询数据,例如数据分析,最好放弃使用缓存。使用缓存最麻烦的就是保持源数据和缓存的中的数据一致。缓存(Cache)依赖,就是缓存是否更新依赖于其它Object。.net的缓存依赖主要用到的类就是CacheDependency、SqlCacheDependency、AggregateCacheDependen …… 阅读全文

Sql Server 数据库中调用dll文件

1.首先新建一个空的解决方案,并添加一个类库,代码如下,编译并生产dllusing System; using System.Collections.Generic; using System.Data.SqlTypes; using System.Linq; using System.Text; namespace TEST { public cla …… 阅读全文

sqlserver 使用脚本创建Sql Server代理作业

use masterGO/* --开启sql server代理sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Agent XPs', 1; GO RECONFIGURE GO*/--定义创建作业DECLARE @jobid uniquei …… 阅读全文