ASP.Net + SQL Server ´æ´¢¹ý³ÌʵÏÖ·ÖÒ³ÅÅÐò
ÎÊÌâÌá³ö:
ÔÚÓ¦ÓóÌÐòÖо³£ÐèÒª²éѯÊý¾Ý¡£µ±²éѯ½á¹ûÊý¾ÝÁ¿±È½Ï´óµÄʱºò£¬¼ìË÷½á¹û¡¢½çÃæÏÔʾ¶¼ÐèÒª»¨·Ñ´óÁ¿µÄʱ¼ä¡£ÎªÁ˱ÜÃâÕâ¸öÎÊÌ⣬Ӧ¸Ãÿ´ÎÖ»¼ìË÷²¿·ÖÊý¾Ý£¬Ò²¾ÍÊÇʹÓó£¼ûµÄ·ÖÒ³·½Ê½À´´¦Àí¡£·ÖÒ³µÄÎÊÌâÔÚasp.netÖкÃÏñ·Ç³£¼òµ¥£¬Ö»ÒªÔÚGridViewÖÐÆôÓ÷ÖÒ³¾Í¿ÉÒÔÁË¡£ÆôÓ÷ÖÒ³ºó£¬GridView¹ØÁªÊý¾ÝÔ´¿Ø¼þ£¬ÒÀ¾É»á¼ÓÔØËùÓеÄÊý¾Ý¡£Õâ¸ö½â¾ö·½·¨Ö»ÊÇ“ÑÚ¶úµÁÁå” £¬»áµ¼ÖÂÔÚ´óÊý¾ÝÁ¿µÄÇé¿öϵ¼Ö²éѯµÄЧÂʱäµÍ¡£
½â¾ö·½·¨£º
ʹÓÃGridViewµÄ×Ô¶¨Òå·ÖÒ³¹¦ÄÜ¡£Ê¹ÓÃ×Ô¶¨Òå·ÖÒ³¹¦ÄÜÐèҪʵÏÖÁ½¸öÂß¼£ºµÃµ½½á¹û¼¯µÄ×ÜÊý¡¢²éÕÒ×Ô¶¨·¶Î§µÄÊý¾Ý¡£
GridView ·ÖҳʵÏÖ£¬¿ÉÒԲο¼ Scott Mitchell ÎÄÕ Efficiently Paging Through Large Amounts of Data
±¾ÎÄ×éÒª½éÉÜÈçºÎÔÚʹÓÃSQL Server ʵÏÖÅÅÐò»ñÈ¡·ÖÒ³Êý¾Ý¡£
1¡¢Ê¹ÓÃ×Ó²éѯ+TOP¹Ø¼ü×Ö·½Ê½
if object_id('GetStudentPaged') is not null
drop procedure GetStudentPaged;
go
/************************************
* ÃèÊö£º ²éÕÒÖ¸¶¨·¶Î§µÄ¼Ç¼
* ²ÎÊý£º@startRow Æäʵ¼Ç¼
* @maximumRows ×î´óµÄ¼Ç¼ÊýÁ¿
*************************************/
create procedure GetStudentPaged
@startRow int,
@maxmimumRows int
as
select top (@maxmimumRows) * from Student
where StudentId NOT IN( select top(@startRow) StudentId from Student )
go
Èç¹ûÐèÒª°´Ìõ¼þ²éÕÒ£¬Ìõ¼þ¿ÉÄÜ»áÓÐËù²»Í¬¡£Í¨¹ý²ÎÊý½«whereÌõ¼þ´«Èëµ½´æ´¢¹ý³ÌÖС£ÓÉÓÚwhere×Ӿ䲻֧³ÖʹÓñäÁ¿£¬ËùÒÔÐèÒª½«ÔÚ´æ´¢¹ý³ÌÖÐ×éºÏSQLÓï¾ä£¬Í¨¹ý¶¯Ì¬SQL·½Ê½Ö´ÐС£
create procedure GetStudentPaged
@startRow int,
@maxmimumRows int,
@whereExpression nvarchar(512)
as
--´æ´¢SQLÓï¾äµÄ×Ö·û´®
declare @sql nvarchar(max)
set @sql = N'Select Top(' + ltrim(str(@maxmimumRows)) + N') * '
set @sql = @sql + N' from Student where '
--ÅжÏÊÇ·ñÓвéѯÌõ¼þ
if @whereExpression is not null and @whereExpression <> N''
begin
set @sql = @sql + @whereExpression + N' and '
end
set @sql = @sql + N'StudentId NOT IN ('
set @sql = @sql + N'Select Top('+ ltrim(str(@
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
PowerDesignerÉú³ÉSQL½Å±¾Ê±±íÃû¡¢×Ö¶ÎÃû´øÒýºÅÎÊÌâ
ʹÓÃPowerDesignerÉú³ÉÊý¾Ý¿â½Å±¾Ê±£¬±íÃûÒ»°ã»á´øÒýºÅ¡£ÈçÏ£º
¼ÓÒýºÅÊÇPL/SQLµÄ¹æ·¶£¬Êý¾Ý¿â»áÑϸñ°´ÕÕ“”ÖеÄÃû³Æ½¨±í£¬Èç¹ûûÓГ”£¬»á°´ÕÕORACLEĬÈϵÄÉèÖý¨±í£¬Ä¬ÈÏÊÇÈ«²¿´óд£ ......
SQL Server¸ù¾Ý²éѯ½á¹û,Éú³ÉXMLÎļþ
À´Ô´£º²»Ïê ×÷ÕߣºØýÃû ʱ¼ä£º2009-3-6 22:15:58 ·¢²¼£ººÚ¿ÍÈí¼þÔ°
/*
'bcp' ²»ÊÇÄÚ²¿»òÍⲿÃüÁҲ²»ÊÇ¿ÉÔËÐеijÌÐò£¿
¿´¿´ÔÚC:\Program Files\Microsoft SQL Server\80\Tools\BinnÀïÃæÓÐûÓÐbcp.exeÕâ¸öÎļþ
È»ºó¿´¿´pathÀïÃæ¼ÓC:\Program Files\Microso ......
--¾ÛºÏº¯Êý
use pubs
go
select avg(distinct price) --Ëãƽ¾ùÊý
from titles
where type='business'
go
use pubs
go
select max(ytd_sales) --×î´óÊý
from titles
go
use pubs
go
select min(ytd_sales) --×îСÊý
from titles
go
use pubs
go
select type,sum(price),sum(advance)  ......
ÆäʵÄã¿ÉÒÔʹÓÃÊÂÎñ´¦Àí
±È·½ËµÔÚÒ»¸ö×Ö¶ÎÀïÃæÌí¼ÓÒ»¸öboolean µÄ×ֶε±ÄãÒª´¦Àí¸Ã×ֶεÄʱºò¾Í True ÄÄô±ðµÄÈ˶¼²»¿ÉÒÔ½øÐвÙ×÷
¡¡Èç¹ûÊÇFalse ÄÄô¾Í¿ÉÒÔ½øÐвÙ×÷¡«¡«ºÇ¿É¡«¡«ÎÒÊÇÕâÑùµÄ
¡¡¡¡²»¹ýÄã¿ÉÒÔ¿´¿´¡¡
¡¡SQLËø»úÖÆ
¡¡¡¡ÒÔÏÂÊÇÎÒÕÒµÄһЩÁÏ¡¡Èç¹ûÒªÀí½âSQLËø»úÖÆ ×îºÃ°ÑÏÂÀ´¿´ÍêŶ
ĬÈϵÄÊÂÎñ¸ôÀë¼ ......