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


相关文档:

mysql,sqlserver,oracle三种数据库的大对象存取

mysql 大对象存取:
  类型一般应该用mediumblod,
  blob只能存2的16次方个byte,
  mediumblod是24次方,
  一般来说够用了.longblob是32次方有些大.
  MYSQL默认配置只能存1M大小的文件,要修改配置,WIN版本的在mysql.ini文件中
  修改max_allowed_packet,net_buffer_length等几个参数,或直接SET GLOBAL va ......

.net学习总结(6)之sqlserver 自定义函数与存储过程

 21 一个SQLServer的自定义函数中调用一个自定义的存储过程,执行此函数后发出如下提示:“只有函数和扩展存储过程才能从函数内部执行"。
 原因:函数只能使用简单的sql语句,逻辑控制语句,复杂一点的存储过程是不能调用的,在函数里也不能使用execute  sp_executesql  或者execute 。解决方法把 ......

SQLServer和Oracle常用函数对比


数学函数
在oracle 中distinct关键字可以显示相同记录只显示一条
  1.绝对值
  S:select abs(-1) value
  O:select abs(-1) value from dual
  2.取整(大)
  S:select ceiling(-1.001) value
  O:select ceil(-1.001) value from dual
  3.取整(小)
  S:select floor(-1.001) value ......

关于oracle导入sqlserver存在的唯一索引问题

我在把oracle数据导入sqlserver中时,发现在oracle中字段定义为唯一索引时,不同记录的此字段如果为空不被认为是重复的,但在sqlserver中如果此字段为唯一索引字段,不允许有2个以上的空值。郁闷。所以只好将sqlserver中的唯一索引字段手工修改为几个非空的值,但这样程序肯定要进行修改了。需要在程序中为此字段设置不重复 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号