易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL 常用存储过程

常用存储过程集锦,都是一些mssql常用的一些,大家可以根据需要选择使用。
  =================分页==========================
  /*分页查找数据*/
  CREATE PROCEDURE [dbo].[GetRecordSet]
  @strSql varchar(8000),--查询sql,如select * from [user]
  @PageIndex int,--查询当页号
  @PageSize int--每页显示记录
  AS
  set nocount on
  declare @p1 int
  declare @currentPage int
  set @currentPage = 0
  declare @RowCount int
  set @RowCount = 0
  declare @PageCount int
  set @PageCount = 0
  exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --得到总记录数
  select @PageCount=ceiling(1.0*@rowCount/@pagesize) --得到总页数
  ,@currentPage=(@PageIndex-1)*@PageSize+1
  select @RowCount,@PageCount
  exec sp_cursorfetch @p1,16,@currentPage,@PageSize
  exec sp_cursorclose @p1
  set nocount off
  GO
  =========================用户注册============================
  /*
  用户注册,也算是添加吧
  */
  Create proc [dbo].[UserAdd]
  (
  @loginID nvarchar(50),     --登录帐号
  @password nvarchar(50), --密码
  @email nvarchar(200) --电子信箱
  )
  as
  declare @userID int --用户编号
  --登录账号已经被注册
  if exists(select loginID from tableName where loginID = @loginID)
  begin
  return -1;
  end
  --邮箱已经被注册
  else if exists(select email from tableName where email = @email)
  begin
  return -2;
  end
  --注册成功
  else
  begin
  select @userID = isnull(max(userID),100000)+1 from tableName
  insert into tableName
  (userID,loginID,[password],userName,linkNum,address,email,createTime,status)
  values
  (@userID,@loginID,@password,'','','',@email,getdate(),1)
  return @userID
  end
==========================sql server系统存储过程===================
  –1.给表中字段添加描述信息
  Create table T2 (id int , name char (20))
  


相关文档:

sql 存储过程生成sql 插入语句

在查询分析器以“文本显示结果”方法执行 
exec  UspOutputData  你的表名 
得到导出数据的语句,但image,text,ntext,sql_variant  列不出现在语句,以后改进。 
 
存储过程UspOutputData如下: 
 
CREATE      PROCEDURE  ......

页面传值验证(防SQL注入)


Global.asax文件中
在页面跳转时,防止传值的参数中SQL注入:
void Application_BeginRequest(object sender, EventArgs e)
    {
        ProcessRequest();
    }
void ProcessRequest()
    {
        try
......

SQL SERVER的数据类型

.SQL SERVER的数据类型
  数据类弄是数据的一种属性,表示数据所表示信息的类型。任何一种计算机语言都定义了自己的数据类型。当然,不同的程序语言都具有不同的特点,所定义的数据类型的各类和名称都或多或少有些不同。SQLServer 提供了 25 种数据类型:
  ·Binary [(n)]
  ·Varbinary [ ......

SQL Server2000中死锁经验总结

虽然不能完全避免死锁,但可以使死锁的数量减至最少。将死锁减至最少可以增加事务的吞吐量并减少系统开销,因为只有很少的事务:
回滚,而回滚会取消事务执行的所有工作。
由于死锁时回滚而由应用程序重新提交。
下列方法有助于最大限度地降低死锁:
按同一顺序访问对象。
避免事务中的用户交互。
保持事务简短 ......

[SQL Server2008]SQL Server 中.与::的区别(转)

SQL Server中调用方法时,经常遇到.或是::两种调用方法,其中. 是实例调用方法,::是静态调用方法。如果大家对C#语法熟悉的话,. 对应C#中调用实例方法,:: 对应C#中的static方法。
下面给出一个SQL Server的实例,下面的SQL运行在2008环境下:
DECLARE @g geography;
SET @g = geography::Parse('LINESTRING(-122.360 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号