SQL³£Ó÷ÖÒ³µÄ°ì·¨ תÔØ
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£º
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
(SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
from ±íÃû
ORDER BY ID))
ORDER BY ID
//×Ô¼º»¹¿ÉÒÔ¼ÓÉÏһЩ²éѯÌõ¼þ
Àý:
select top 2 *
from Sys_Material_Type
where (MT_ID not in
(select top (2*(3-1)) MT_ID from Sys_Material_Type order by MT_ID))
order by MT_ID
2.·ÖÒ³·½°¸¶þ£º(ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³£©
Óï¾äÐÎʽ£º
SELECT TOP ÿҳ¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID >
(SELECT MAX(id)
from (SELECT TOP ÿҳÐÐÊý*Ò³Êý id from ±í
ORDER BY id) AS T)
)
ORDER BY ID
Àý:
SELECT TOP 2 *
from Sys_Material_Type
WHERE (MT_ID >
(SELECT MAX(MT_ID)
from (SELECT TOP (2*(3-1)) MT_ID
from Sys_Material_Type
ORDER BY MT_ID) AS T))
ORDER BY MT_ID
3.·ÖÒ³·½°¸Èý£º(ÀûÓÃSQLµÄÓαê´æ´¢¹ý³Ì·ÖÒ³)
create procedure SqlPager
@sqlstr nvarchar(4000), --²éѯ×Ö·û´®
@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
4.×ܽá:
ÆäËüµÄ·½°¸£ºÈç¹ûûÓÐÖ÷¼ü£¬¿ÉÒÔÓÃÁÙʱ±í£¬Ò²¿ÉÒÔÓ÷½°¸Èý×ö£¬µ«ÊÇЧÂÊ»áµÍ¡£
½¨ÒéÓÅ»¯µÄʱºò£¬¼ÓÉÏÖ÷¼üºÍË÷Òý£¬²éѯЧÂÊ»áÌá¸ß¡£
ͨ¹ýSQL ²éѯ·ÖÎöÆ÷£¬ÏÔʾ±È½Ï£ºÎҵĽáÂÛÊÇ:
·ÖÒ³·½°¸¶þ£º(ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³£©Ð§ÂÊ×î¸ß£¬ÐèҪƴ½ÓSQLÓï¾ä
·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³) ЧÂÊ´ÎÖ®£¬ÐèҪƴ½ÓSQLÓï¾ä
·ÖÒ³·½°¸Èý£º(ÀûÓÃSQLµÄÓαê´æ´¢¹ý³Ì·ÖÒ³) ЧÂÊ×î²î£¬µ«ÊÇ×îΪͨÓÃ
Ïà¹ØÎĵµ£º
I'm continually trying to track down what service packs are installed on various SQL Servers I support. I can never find the right support page on Microsoft's site. So here's an article with all the SQL Server version information I can track down. If you know of any older versions or can help me fil ......
·¢±íϱ¾È˽øÐЩ¶´ÍÚ¾òµÄÊ×ƪԴ´ÎÄÕ£º
¶ÔDiscuz nT3.0½øÐÐÁË·ÖÎö£¬·¢ÏÖspacemanage.aspxÒ³Ãæ´æÔÚÒ»¸ö×¢È멶´£¬
¸ÃÒ³ÃæλÖãºdnt3_src\dnt3\Discuz.Web\space\Admin
´úÂëÈçÏ£º
public void BindData()
{
DataGrid1.AllowCustomPaging = true;
string username = Usernam ......
SQL±¦µä
SQL±ØÖª±Ø»áµÚÈý°æ
SQLÈëÞµäµÚËÄ°æ
Sams Teach Yourself SQL in 10 Minutes Third Edition
SQL The Complete Reference
......
Ò»£ºSelectÓï¾ä£º
select ×Ö¶ÎÃû from ±íÃû where Ìõ¼þ order by ÅÅÐò
see:select distinct ´Ó¶à¸öÏàͬ×Ö¶ÎÖÐץΨһֵ
see:²éÕÒld_det_andy±íÖÐÓÐÊý¾Ýµ«ld_det_temp±íÖÐûÊý¾ÝµÄÊý¾Ý
select * from ld_det_a ......
http://www.cnblogs.com/yinzhenzhixin/archive/2009/01/07/1371064.html
ÔÚSQLÓï¾äÖУ¬UNION¹Ø¼ü×Ö¶àÓÃÀ´½«²¢ÁеĶà×é²éѯ½á¹û(±í)ºÏ²¢³ÉÒ»¸ö½á¹û(±í)£¬¼òµ¥ÊµÀýÈçÏ£º
SELECT [Id],[Name],[Comment] from [Product1]
UNION
SELECT [Id],[Name],[Comment] from [Product2]
ÉÏÃæµÄ´úÂë¿ ......