Sql NewId() Ëæ»úÊý £¨×ª£©
´ÓA±íËæ»úÈ¡10Ìõ¼Ç¼,ÓÃSELECT TOP 10 * from ywle order by newid()
order by Ò»°ãÊǸù¾Ýijһ×Ö¶ÎÅÅÐò,newid()µÄ·µ»ØÖµ ÊÇuniqueidentifier ,order by newid()Ëæ»úÑ¡È¡¼Ç¼ÊÇÈçºÎ½øÐеÄ
newid()ÔÚɨÃèÿÌõ¼Ç¼µÄʱºò¶¼Éú³ÉÒ»¸öÖµ, ¶øÉú³ÉµÄÖµÊÇËæ»úµÄ, ûÓдóСд˳Ðò. ËùÒÔ×îÖÕ½á¹ûÔÙ°´Õâ¸öÅÅÐò, ÅÅÐòµÄ½á¹ûµ±È»¾ÍÊÇÎÞÐòµÄÁË
»òÕß
select top 10 *,newid() as Random from ywle where ywlename='001' ordey by Random
ÏÂÕßЧÂÊÒª¸ßЩ
ÒòΪnewid()·µ»ØµÄÊÇuniqueidentifierÀàÐ͵ÄΨһֵ¡£newid()ÿ´Î²úÉúµÄÖµ¶¼²»Ò»Ñù£¬ÄÇô¸ù¾ÝÕâÑùµÄÖµ½øÐÐÅÅÐò£¬Ã¿´ÎµÄ½á¹ûÒ²ÊDz»Ò»ÑùµÄ¡£
ÔÀíÊÇ °ÑËùÓеÄID³öÈ¡È»ºóÓÃËæ»úº¯ÊýÈ¡³öÆäÖÐÒ»¸ö,È»ºóÓÃÕâ¸öËæ»úÈ¡µ½µÄIDÈ¥Êý¾Ý¿âÀïÔÙÈ¡³ö¼Ç¼£¬ËùÓдú¼ÛÓеã´ó¡£
sql serverµÄËæ»úº¯ÊýnewID()ºÍRAND()
SELECT * from Northwind..Orders ORDER BY NEWID()
--Ëæ»úÅÅÐò
SELECT TOP 10 * from Northwind..Orders ORDER BY NEWID()
--´ÓOrders±íÖÐËæ»úÈ¡³ö10Ìõ¼Ç¼
ʾÀý
A.¶Ô±äÁ¿Ê¹Óà NEWID º¯Êý
ÒÔÏÂʾÀýʹÓà NEWID() ¶ÔÉùÃ÷Ϊ uniqueidentifier Êý¾ÝÀàÐ͵ıäÁ¿¸³Öµ¡£ÔÚ²âÊÔ uniqueidentifier Êý¾ÝÀàÐͱäÁ¿µÄֵ֮ǰ£¬ÏÈÊä³ö¸ÃÖµ¡£
-- Creating a local variable with DECLARESET syntax.
DECLARE @myid uniqueidentifier
SET @myid = NEWID()
PRINT 'Value of @myid is '+ CONVERT(varchar(255), @myid)
ÏÂÃæÊǽá¹û¼¯£º
Value of @myid is 6F9619FF-8B86-D011-B42D-00C04FC964FF
×¢Ò⣺
NEWID ¶Ôÿ̨¼ÆËã»ú·µ»ØµÄÖµ¸÷²»Ïàͬ¡£ËùÏÔʾµÄÊý×Ö½öÆð½âÊÍ˵Ã÷µÄ×÷Óá£
Ëæ»úº¯Êý£ºrand()
ÔÚ²éѯ·ÖÎöÆ÷ÖÐÖ´ÐУºselect rand()£¬¿ÉÒÔ¿´µ½½á¹û»áÊÇÀàËÆÓÚÕâÑùµÄËæ»úСÊý£º0.36361513486289558£¬ÏñÕâÑùµÄСÊýÔÚʵ¼ÊÓ¦ÓÃÖÐÓõò»¶à£¬Ò»°ãҪȡËæ»úÊý¶¼»áÈ¡Ëæ»úÕûÊý¡£ÄǾͿ´ÏÂÃæµÄÁ½ÖÖËæ»úÈ¡ÕûÊýµÄ·½·¨£º
1¡¢
A£ºselect floor(rand()*N) ---Éú³ÉµÄÊýÊÇÕâÑùµÄ£º12.0
B£ºselect cast( floor(rand()*N) as int) ---Éú³ÉµÄÊýÊÇÕâÑùµÄ£º12
2¡¢
A£ºselect ceiling(rand() * N) ---Éú³ÉµÄÊýÊÇÕâÑùµÄ£º12.0
B£ºselect cast(ceiling(rand() * N) as int) ---Éú³ÉµÄÊýÊÇÕâÑùµÄ£º12
ÆäÖÐÀïÃæµÄNÊÇÒ»¸öÄãÖ¸¶¨µÄÕûÊý£¬Èç1
Ïà¹ØÎĵµ£º
SQL Server ¾Ñé £¨×ªÔØ£©
http://www.cnblogs.com/treeyh/archive/2007/08/06/844763.html
Èç¹ûÄãÕýÔÚ¸ºÔðÒ»¸ö»ùÓÚSQL ServerµÄÏîÄ¿£¬»òÕßÄã¸Õ¸Õ½Ó´¥SQL Server£¬Ä㶼ÓпÉÄÜÒªÃæÁÙһЩÊý¾Ý¿âÐÔÄܵÄÎÊÌ⣬ÕâƪÎÄÕ»áΪÄãÌṩһЩÓÐÓõÄÖ¸µ¼£¨ÆäÖдó¶àÊýÒ²¿ÉÒÔÓÃÓÚÆäËüµÄDBMS£©¡£
ÔÚÕâÀÎÒ²»´òËã½éÉ ......
[Sql]EXCEPT ºÍ INTERSECT¹Ø¼ü×Ö
http://www.cnblogs.com/treeyh/archive/2008/07/01/1232845.html
EXCEPT
´Ó EXCEPT ²Ù×÷Êý×ó±ßµÄ²éѯÖзµ»ØÓұߵIJéѯδ·µ»ØµÄËùÓзÇÖظ´Öµ¡£
INTERSECT
·µ»Ø INTERSECT ²Ù×÷Êý×óÓÒÁ½±ßµÄÁ½¸ö²éѯ¾ù·µ»ØµÄËùÓзÇÖظ´Öµ¡£
A. ʹÓà EXCEPT
ÔÚʾÀýÖÐʹÓà TableA ºÍ TableB ÖеÄÊý¾Ý¡£
......
http://www.sql-server-performance.com/tips/clustered_indexes_p1.aspx
As a rule of thumb, every table should have a clustered index. Generally, but not always, the clustered index should be on a column that monotonically increases--such as an identity column, or some other column where the value is ......
'SQL·À×¢È뺯Êý£¬µ÷Ó÷½·¨£¬ÔÚÐèÒª·À×¢ÈëµÄµØ·½Ìæ»»ÒÔÇ°µÄrequest("XXXX")ΪSafeRequest("XXXX")
'www.yongfa365.com
Function
SafeRequest(ParaValue)
ParaValue =
Trim
(
Request
(Pa ......
--Excelµ¼ÈëSQL SERVERÖÐ
--±í½á¹¹²»´æÔÚ¿ÉÒÔʹÓÃ
--ÆôÓÃAd Hoc Distributed Queries£º
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
select * into serv_user_bak1 from
OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=yes;dat ......