¼òµ¥µÄ sql·ÖÒ³´æ´¢¹ý³Ì
¡¾1¡¿
create procedure proc_pager1
( @pageIndex int, -- ҪѡÔñµÚXÒ³µÄÊý¾Ý
@pageSize int -- ÿҳÏÔʾ¼Ç¼Êý
)
AS
BEGIN
declare @sqlStr varchar(500)
set @sqlStr='select top '+convert(varchar(10),@pageSize)+
' * from orders where orderid not in(select top '+
convert(varchar(20),(@pageIndex-1)*@pageSize)+
' orderid from orders) order by orderid'
exec (@sqlStr)
END
¡¾2¡¿
create procedure proc_pager
( @startIndex int,--¿ªÊ¼¼Ç¼Êý
@endIndex int --½áÊø¼Ç¼Êý
)
as
begin
declare @indextable table(id int identity(1,1),nid int)
insert into @indextable(nid) select orderid from orders order by orderid desc
select *
from orders o
inner join @indextable i
on o.orderid=i.nid
where i.id between @startIndex and @endIndex
order by i.id
end
¡¾3¡¿ÊÊÓÃÓÚsql2005
create procedure proc_pager2
( @startIndex int,--¿ªÊ¼¼Ç¼Êý
@endIndex int --½áÊø¼Ç¼Êý
)
as
begin
WITH temptbl AS
(SELECT ROW_NUMBER() OVER (ORDER BY orderid DESC) AS Row, *from orders)
SELECT * from temptbl
where row between @startIndex and @endIndex
order by row
end
Ïà¹ØÎĵµ£º
#include "iostream.h"
#include "stdio.h"
#import "C:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
int main(int argc, char* argv[])
{
::CoInitialize(NULL);
_ConnectionPtr m_pConnection;
m_pConnection.CreateInstance("ADODB.Connection");
tr ......
CREATE proc sqlToMultiExcelFile
@sqlstr nvarchar(4000), --²éѯÓï¾ä,Èç¹û²éѯÓï¾äÖÐʹÓÃÁËorder by ,Çë¼ÓÉÏtop 100 percent
@primaryKey varchar(100),--·ÖÒ³Ö÷¼ü×Ö¶Î
@path nvarchar(1000), --Îļþ´æ·ÅĿ¼
@fname nvarchar(250), --ÎļþÃû
@sheetname varchar(250)='sheet1' --Òª´´½¨µÄ¹¤×÷±íÃû,Ä ......
use Tempdb
go
if object_ID('fn_ACITEncryption') is not null
drop function fn_ACITEncryption
go
create function fn_ACITEncryption
(
@Str nvarchar(4000),--¼ÓÃܵÄ×Ö·û´®
@Flag bit=1,--1¡¢¼ÓÃÜ 0¡¢½âÃÜ
@Key nvarchar(50)--ÃÜÎÄ
)
returns nvarchar(4000)--這Àï¿É轉換 ......
SQL°´ÕÕÈÕ¡¢ÖÜ¡¢Ô¡¢Äêͳ¼ÆÊý¾Ý ÊÕ²Ø
ÎÄÕ²ο¼£ºhttp://www.cnblogs.com/wenbhappy/archive/2008/07/02/1233660.html
Èç:
±í:consume_record
×Ö¶Î:consume (moneyÀàÐÍ)
date (datetimeÀàÐÍ)
ÇëÎÊÔõôдËÄÌõsqlÓï¾ä·Ö±ð°´ÈÕ,°´ÖÜ,°´ÔÂ,°´¼¾Í³¼ÆÏû·Ñ×ÜÁ¿.
Èç:1ÔÂ 1200Ô ......
create table tb (ptoid int,proclassid int,proname varchar(10))
insert tb
select 1,1,'Ò·þ1'
union all
select 2,2,'Ò·þ2'
union all
select 3,3,'Ò·þ3'
union all
select 4,3,'Ò·þ4'
union all
select 5,2,'Ò·þ5'
union all
select 6,2,'Ò·þ6'
union all
select 7,2,'Ò·þ7'
union all
select 8 ......