易截截图软件、单文件、免安装、纯绿色、仅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))
  


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

SQL语法,SQL语句大全,SQL基础

SQL 语法参考手册(SQL)/数据类型
2006-07-24 07:42
《SQL 语法参考手册(SQL)》
DB2 提供了关连式资料库的查询语言 SQL (Structured Query Language),是一种非常口语化、既易学又易懂的语法。此一语言几乎是每个资料库系统都必须提供的,用以表示关连式的*作,包含 ......

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


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

SQL SERVER临时表的使用


drop table #Tmp   --删除临时表#Tmp
create table #Tmp --创建临时表#Tmp
(
    ID   int IDENTITY (1,1)     not null, --创建列ID,并且每次新增一条记录就会加1
    WokNo          &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号