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

Sqlserver 存储过程大集合

 =================分页==========================
/*分页查找数据*/
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))
GO
EXEC sp_addextendedproperty 'MS_Description', 'Employee ID', 'user', dbo, 'table', T2, 'column', id
EXEC sp_updateextendedproperty 'MS_Description', 'this is a test', 'user', dbo, 'table', T2, 'column', id
–2.修改数据库名称
EXEC sp_renamedb 'old_db_nam


相关文档:

SQLSERVER 2000 convert函数转换日期格式


SQLserver中用convert函数转换日期格式
2008-01-23 15:47
SQLserver中用convert函数转换日期格式2008-01-15 15:51SQLserver中用convert函数转换日期格式
SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm
例如:
select getdate()
2004-09-12 11:06:08.177
整理了一下SQL Server里面可能经 ......

SQLServer数据库

 Sybase SQL Server体系结构介绍
摘要:本文主要对Sybase SQL Server体系结构进行介绍,便于读者对Sybase SQL Server有个整体大概的了解。
标签:Sybase SQL Server  Sybase  SQL Server  体系结构
 
Sybase SQL Server是一个多库结构的RDBMS,体系结构大致如下:
1.数据库 ......

一只查询SQLServer 2005所有信息的语句

select
    table_name=
    (
    case when t_c.column_id=1
        then t_o.name
        else ''
    end
    ),
    column_id=t_ ......

Sqlserver 取汉字的第一个字母,方便模糊查询

 create function comm_getpy
(
    @str nvarchar(4000)
)
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
    set @word=left(@str,1)
    --如果非汉字字符,返回原字符
& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号