sql server Ë÷Òý¹ÜÀíÁù´óÌúÂÉ
ÎÄÕÂÀ´Ô´£ºIT¹¤³Ì¼¼ÊõÍø http://www.systhinker.com/?viewnews-11609
ÌúÂÉÒ»£ºÌìÏÂûÓÐÃâ·ÑµÄÎç²Í£¬Ê¹ÓÃË÷ÒýÊÇÐèÒª¸¶³ö´ú¼ÛµÄ¡£
¡¡¡¡Ë÷ÒýµÄÓŵãÓÐÄ¿¹²¶Ã£¬µ«ÊÇ£¬È´ºÜÉÙÓÐÈ˹ØÐĹý²ÉÓÃË÷ÒýËùÐèÒª¸¶³öµÄ³É±¾¡£ÈôÊý¾Ý¿â¹ÜÀíÔ±Äܹ»¶ÔË÷ÒýËùÐèÒª¸¶³öµÄ´ú¼ÛÓÐÒ»¸ö³ä·ÖµÄÈÏʶ£¬Ò²¾Í²»»áÄÇôËæÒâµ½´¦½¨Á¢Ë÷ÒýÁË¡£
¡¡¡¡×ÐϸÊýÊý£¬Æäʵ½¨Á¢Ë÷ÒýµÄ´ú¼Û»¹ÊÇÂù´óµÄ¡£Èç´´½¨Ë÷ÒýºÍά»¤Ë÷Òý¶¼ÐèÒª»¨·Ñʱ¼äÓ뾫Á¦¡£ÌرðÊÇÔÚÊý¾Ý¿âÉè¼ÆµÄʱºò£¬Êý¾Ý¿â¹ÜÀíԱΪ±íÖеÄÄÄЩ×Ö¶ÎÐèÒª½¨Á¢Ë÷Òý£¬Òªµ÷ÑС¢ÒªÐµ÷¡£Èçµ±½¨ÓÐË÷ÒýµÄ±íÖеļͼÓÖÔö¼Ó¡¢É¾³ý¡¢Ð޸IJÙ×÷ʱ£¬Êý¾Ý¿âÒª¶ÔË÷Òý½øÐÐÖØе÷Õû¡£ËäÈ»Õâ¸ö¹¤×÷Êý¾Ý¿â×Ô¶¯»áÍê³É£¬µ«ÊÇ£¬ÐèÒªÏûºÄ·þÎñÆ÷µÄ×ÊÔ´¡£µ±±íÖеÄÊý¾ÝÔ½¶à£¬Õâ¸öÏûºÄµÄ×ÊÔ´Ò²¾ÍÔ½¶à¡£ÈçË÷ÒýÊÇÊý¾Ý¿âÖÐʵ¼Ê´æÔڵĶÔÏó£¬ËùÒÔ£¬Ã¿¸öË÷Òý¶¼»áÕ¼ÓÃÒ»¶¨µÄÎïÀí¿Õ¼ä¡£ÈôË÷Òý¶àÁË£¬²»µ«»áÕ¼ÓôóÁ¿µÄÎïÀí¿Õ¼ä£¬¶øÇÒ£¬Ò²»áÓ°Ïìµ½Õû¸öÊý¾Ý¿âµÄÔËÐÐÐÔÄÜ¡£
¡¡¡¡¿É¼û£¬Êý¾Ý¿â¹ÜÀíÔ±ÈôÒª²ÉÓÃË÷ÒýÀ´Ìá¸ßϵͳµÄÐÔÄÜ£¬×ÔÉíÈÔÈ»ÐèÒª¸¶³ö²»ÉٵĴú¼Û¡£Êý¾Ý¿â¹ÜÀíÔ±ÏÖÔÚÒª¿¼ÂǵľÍÊÇÈçºÎÔÚÕâÁ½¸öÖ®¼äÈ¡µÃÒ»¸ö¾ùºâ¡£»òÕß˵£¬ÕÒµ½Ò»¸ö»Ø±¨ÓëͶÈëµÄÁÙ½çµã¡£
ÌúÂɶþ£º¶ÔÓÚ²éѯÖкÜÉÙÉæ¼°µÄÁлòÕßÖظ´Öµ±È½Ï¶àµÄÁУ¬²»Òª½¨Á¢Ë÷Òý¡£¡¡
¡¡ÔÚ²éѯµÄʱºò£¬Èç¹ûÎÒÃDz»°´Ä³¸ö×Ö¶ÎÈ¥²éѯ£¬ÔòÔÚÕâ¸ö×Ö¶ÎÉϽ¨Á¢Ë÷ÒýÒ²ÊÇÀË·Ñ¡£ÈçÏÖÔÚÓÐÒ»ÕÅÔ±¹¤ÐÅÏ¢±í£¬ÎÒÃÇ¿ÉÄÜ°´Ô±¹¤±àºÅ¡¢Ô±¹¤ÐÕÃû¡¢»òÕß³öÉíµØÈ¥²éѯԱ¹¤ÐÅÏ¢¡£µ«ÊÇ£¬ÎÒÃÇÍùÍù²»»á°´ÕÕÉí·ÝÖ¤ºÅÂëÈ¥²éѯ¡£ËäÈ»Õâ¸öÉí·ÝÖ¤ºÅÂëÊÇΨһµÄ¡£´Ëʱ£¬¼´Ê¹ÔÚÕâ¸ö×Ö¶ÎÉϽ¨Á¢Ë÷Òý£¬Ò²²»Äܹ»Ìá¸ß²éѯµÄËٶȡ£Ïà·´£¬Ôö¼ÓÁËϵͳά»¤Ê±¼äºÍÕ¼ÓÃÁËϵͳ¿Õ¼ä¡£Õâ¼òÖ±¾ÍÊÇ°áÆðʯͷÔÒ×Ô¼ºµÄ½Åѽ¡£
ÁíÍ⣬ÈçÉÏÃæµÄÔ±¹¤ÐÅÏ¢±í£¬ÓÐЩ×Ö¶ÎÖظ´Öµ±È½Ï¶à¡£ÈçÐÔ±ð×Ö¶ÎÖ÷Òª¾ÍÊÇ“ÄД¡¢“Å®”;ְλ×Ö¶ÎÖÐÒ²ÊÇÓÐÏ޵ļ¸¸öÄÚÈÝ¡£´Ëʱ£¬ÔÚÕâЩ×Ö¶ÎÉÏÌí¼ÓË÷ÒýÒ²²»»áÏÔÖøµÄÔö¼Ó²éѯËٶȣ¬¼õÉÙÓû§ÏìӦʱ¼ä¡£Ïà·´£¬ÒòΪÐèÒªÕ¼Óÿռ䣬·´¶ø»á½µµÍÊý¾Ý¿âµÄÕûÌåÐÔÄÜ¡£
¡¡¡¡Êý¾Ý¿âË÷Òý¹ÜÀíÖеĵڶþÌõÌúÂɾÍÊÇ£¬¶ÔÓÚ²éѯÖкÜÉÙÉæ¼°µÄÁлòÕßÖظ´Öµ±È½Ï¶àµÄÁУ¬²»Òª½¨Á¢Ë÷Òý¡£
ÌúÂÉÈý£º¶ÔÓÚ°´·¶Î§²éѯµÄÁУ¬×îºÃ½¨Á¢Ë÷Òý¡£
¡¡¡¡ÔÚÐÅÏ¢»¯¹ÜÀíϵͳÖУ¬ºÜ¶àʱºòÐèÒª°´·¶Î§À´²éѯijЩ½»Ò׼Ǽ¡£ÈçÔÚERPϵͳÖУ¬¾³£ÐèÒª²éѯµ±ÔµÄÏúÊÛ¶©µ¥ÓëÏúÊÛ³ö»õÇ
Ïà¹ØÎĵµ£º
declare @p int
declare @p1 int
declare @count int
set @p=0
set @p1=10
set @count=2
if(@count<>0 or @count<>1)
set @p=@p1*@count-10
SELECT [t1].[userid], [t1].[username], [t1].[userorder]
from (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[userorder]) AS [ROW_NU ......
asc °´ÉýÐòÅÅÁÐ
desc °´½µÐòÅÅÁÐ
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý ......
×òÍí£¬µ½Î¢Èí¹Ù·½ÏÂÁËÒ»¸ö32°æ±¾µÄTrial°æ±¾¡£ÎļþÃûΪSQLFULL_x86_ENU.exe¡£Îļþ´óСΪ1.30G×óÓÒ¡£ÒòΪֻÓÐ32λһ¸ö°æ
±¾£¬±ÈSQL Server 2008ÄǸö3GµÄҪС¶àÁË¡£ºÇºÇ¡£
http://www.microsoft.com/sqlserver/2008/en/us/R2Downloads.aspx
ÏÂ
ÔØÍê³Éºó£¬ÏÈжÔØÔÀ´µÄSQL Server 2008¡¡sp2,½á¹ûÕûÕûÔËÐÐÁËÁ½¸ ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[PE011_Page]
@TableName varchar(50), --±íÃû
@Fields varchar(5000) = '*', --×Ö¶ÎÃû(È«²¿×Ö¶ÎΪ*)
@OrderField varchar(5000), &n ......