一个sql分页的存储过程
CREATE procedure SqlPager_Ex
@sqlstr varchar(8000), --查询字符串
@currentpage int, --第N页
@pagesize int --每页行数,
as
set nocount on
declare @P1 int, --P1是游标的id
@rowcount int
exec sp_cursoropen @P1 output,@sqlstr,@scrollopt=1,@ccopt=1,@rowcount=@rowcount output
select ceiling(1.0*@rowcount /@pagesize) as 总页数 --,@rowcount as 总行数,@currentpage as 当前页
set @currentpage=(@currentpage-1)*@pagesize+1
exec sp_cursorfetch @P1,16,@currentpage,@pagesize
exec sp_cursorclose @P1
set nocount off
GO
相关文档:
将Excel文件数据库导入SQL Server的三种方案
//方案一: 通过OleDB方式获取Excel文件的数据,然后通过DataSet中转到SQL Server
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel files(*.xls)|*.xls";
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FileInfo ......
1.读出表中的字段名
ResultSet rs = test.selectSql("SELECT * from datainfo");
java.sql.ResultSetMetaData md=rs.getMetaData(); //读出数据库的字段名
int nColumn=md.getColumnCount(); //字段总数
for(int i=0;i<nColumn;i++)
& ......
COLLATE 是一个子句,可应用于数据库定义或列定义以定义排序规则,或应用于字符串表达式以应用排序规则转换。
语法
COLLATE { <collation_name> | database_default }
<collation_name> :: =
{ Windows_collation_name } | { SQL_collation_name }
参数
collation_name
  ......
一、加快sql的执行速度
1.select 语句中使用sort,或join
如果你有排序和连接操作,你可以先select数据到一个临时表中,然后再对临时表进行处理。因为临时表是建立在内存中,所以比建立在磁盘上表操作要快的多。
如:
SELECT time_records.*, case_name
from time_records, OUTER cases
WHERE time_re ......
方法一:
打开企业管理器->SQL SERVRE 组->(local)window NT ->属性
产品:有personal的是个人版的,有Enterprise的是企业版的
产品版本:8.00.2039(sp4);8.00.760(sp3)
方法二:
第一步:在查询分析器
select @@version
print @@version
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005 ......