Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¼òµ¥µÄ 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


Ïà¹ØÎĵµ£º

SQL XML DELETE

--A. ´Ó´æ´¢ÔÚ·ÇÀàÐÍ»¯µÄ xml ±äÁ¿ÖеÄÎĵµÖÐɾ³ý½Úµã
DECLARE @myDoc xml
SET @myDoc = '<?Instructions for=TheWC.exe ?>
<Root>
 <!-- instructions for the 1st work center -->
<Location LocationID="10" LaborHours="1.1" MachineHours=".2" >
 Some text 1
 <st ......

SQL Serverº¯Êý´óÈ«

selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'ÔÆ',×Ö¶Î1£©=1; ×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´®ºÍ ......

sqlÖ®left join¡¢right join¡¢inner joinµÄÇø±ð

left join(×óÁª½Ó) ·µ»Ø°üÀ¨×ó±íÖеÄËùÓмǼºÍÓÒ±íÖÐÁª½á×Ö¶ÎÏàµÈµÄ¼Ç¼
right join(ÓÒÁª½Ó) ·µ»Ø°üÀ¨ÓÒ±íÖеÄËùÓмǼºÍ×ó±íÖÐÁª½á×Ö¶ÎÏàµÈµÄ¼Ç¼
inner join(µÈÖµÁ¬½Ó) Ö»·µ»ØÁ½¸ö±íÖÐÁª½á×Ö¶ÎÏàµÈµÄÐÐ
¾ÙÀýÈçÏ£º
--------------------------------------------
±íA¼Ç¼ÈçÏ£º
aID¡¡¡¡¡¡¡¡¡¡aNum
1¡¡¡¡¡¡¡¡¡¡a ......

sql serverÇå³ýÈÕÖ¾

1: ɾ³ýLOG (ɾ³ýlogÎļþ£¬¸½¼Óʱ×Ô¶¯Öؽ¨logÎļþ£¬ÒÔ´Ë·½Ê½À´Çå¿ÕÈÕÖ¾)
    1) ·ÖÀëÊý¾Ý¿â  ÆóÒµ¹ÜÀíÆ÷£­£¾·þÎñÆ÷£­£¾Êý¾Ý¿â£­£¾ÓÒ¼ü£­£¾·ÖÀëÊý¾Ý¿â
    2) ɾ³ýLOGÎļþ
    3) ¸½¼ÓÊý¾Ý¿â  ÆóÒµ¹ÜÀíÆ÷£­£¾·þÎñÆ÷£­£¾Êý¾Ý¿â£­£¾ÓÒ¼ü£­£¾¸½¼ÓÊý¾Ý¿â
´Ë·¨Éú³ ......

sql ¼ÓÃÜ

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) ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ