点击(此处)折叠或打开

  1. /*分页查找数据*/
  2. CREATE PROCEDURE [dbo].[GetRecordSet]
  3. @strSql varchar(8000),--查询sql,如select * from [user]
  4. @PageIndex int,--查询当页号
  5. @PageSize int--每页显示记录
  6. AS
  7. set nocount on
  8. declare @p1 int
  9. declare @currentPage int
  10. set @currentPage = 0
  11. declare @RowCount int
  12. set @RowCount = 0
  13. declare @PageCount int
  14. set @PageCount = 0
  15. exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --得到总记录数
  16. select @PageCount=ceiling(1.0*@rowCount/@pagesize) --得到总页数
  17. ,@currentPage=(@PageIndex-1)*@PageSize+1
  18. select @RowCount,@PageCount
  19. exec sp_cursorfetch @p1,16,@currentPage,@PageSize
  20. exec sp_cursorclose @p1
  21. set nocount off
  22. GO


点击(此处)折叠或打开

  1. /*分页查找数据*/
  2. CREATE PROCEDURE [dbo].[GetRecordSet]
  3. @strSql varchar(8000),--查询sql,如select * from [user]
  4. @PageIndex int,--查询当页号
  5. @PageSize int--每页显示记录
  6. AS
  7. set nocount on
  8. declare @p1 int
  9. declare @currentPage int
  10. set @currentPage = 0
  11. declare @RowCount int
  12. set @RowCount = 0
  13. declare @PageCount int
  14. set @PageCount = 0
  15. exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --得到总记录数
  16. select @PageCount=ceiling(1.0*@rowCount/@pagesize) --得到总页数
  17. ,@currentPage=(@PageIndex-1)*@PageSize+1
  18. select @RowCount,@PageCount
  19. exec sp_cursorfetch @p1,16,@currentPage,@PageSize
  20. exec sp_cursorclose @p1
  21. set nocount off
  22. GO

unity3d脚本http://www.unitymanual.com全新开启

点击(此处)折叠或打开

  1. /*
  2. 用户注册,也算是添加吧
  3. */
  4. Create proc [dbo].[UserAdd]
  5. (
  6. @loginID nvarchar(50),     --登录帐号
  7. @password nvarchar(50), --密码
  8. @email nvarchar(200) --电子信箱
  9. )
  10. as
  11. declare @userID int --用户编号
  12. --登录账号已经被注册
  13. if exists(select loginID from tableName where loginID = @loginID)
  14. begin
  15. return -1;
  16. end
  17. --邮箱已经被注册
  18. else if exists(select email from tableName where email = @email)
  19. begin
  20. return -2;
  21. end
  22. --注册成功
  23. else
  24. begin
  25. select @userID = isnull(max(userID),100000)+1 from tableName
  26. insert into tableName
  27. (userID,loginID,[password],userName,linkNum,address,email,createTime,status)
  28. values
  29. (@userID,@loginID,@password,'','','',@email,getdate(),1)
  30. return @userID
  31. end

SQL Server 系统存储过程

点击(此处)折叠或打开

  1. Create table T2 (id int , name char (20))
  2. GO
  3. EXEC sp_addextendedproperty 'MS_Description', 'Employee ID', 'user', dbo, 'table', T2, 'column', id
  4. EXEC sp_updateextendedproperty 'MS_Description', 'this is a test', 'user', dbo, 'table', T2, 'column', id

2.修改数据库名称

点击(此处)折叠或打开

  1. Create table T2 (id int , name char (20))
  2. GO
  3. EXEC sp_addextendedproperty 'MS_Description', 'Employee ID', 'user', dbo, 'table', T2, 'column', id
  4. EXEC sp_updateextendedproperty 'MS_Description', 'this is a test', 'user', dbo, 'table', T2, 'column', id

2.修改数据库名称

点击(此处)折叠或打开

  1. EXEC sp_renamedb 'old_db_name', 'new_db_name'

3.修改数据表名称和字段名称

点击(此处)折叠或打开

  1. EXEC sp_rename 'old_table_name', 'new_table_name'–修改数据表名称
  2. EXEC sp_rename 'table_name.[old_column_name]', 'new_column_name', 'COLUMN'–修改字段名称


09-21 20:55