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

ACCESSºÍMSSQL ÈçºÎËæ»ú¶ÁÈ¡Êý¾Ý¿â¼Ç¼

²éѯÓï¾äÖ»ÒªÕâÑùд,¾Í¿ÉÒÔËæ»úÈ¡³ö¼Ç¼ÁË
SQL="Select top 6 * from Dv_bbs1 where isbest = 1 and layer = 1 order by newID() desc"
ÔÚACCESSÀï
SELECT top 15 id from tablename order by rnd(id)
SQL Server£º
Select TOP N * from TABLE Order By NewID()
Access£º
Select TOP N * from TABLE Order By Rnd(ID)
Rnd(ID) ÆäÖеÄIDÊÇ×Ô¶¯±àºÅ×ֶΣ¬¿ÉÒÔÀûÓÃÆäËûÈκÎÊýÖµÀ´Íê³É£¬±ÈÈçÓÃÐÕÃû×Ö¶Î(UserName)
Select TOP N * from TABLE Order BY Rnd(Len(UserName))
MySql£º
Select * from TABLE Order By Rand() Limit 10
SQLÊý¾Ý¿âÓиönewidº¯Êý£¬¿ÉÒԺܷ½±ãµÄÓÃSQLÓï¾äµÃµ½±íÖеÄËæ»úÊý¾Ý¡£µ«accessÊý¾Ý¿âûÕâô·½±ã£¬ËäÈ»ÓиöRnd£¬¿ÉÒÔͨ¹ý“select top 10 * from tb order by rnd(id)”µÃµ½Ëæ»úÊý¾Ý£¬¿ÉϧÔÚVBÖÐʹÓ㬲úÉúµÄËæ»úÐòÁÐÊÇÒ»ÑùµÄ¡£
ÓÐÈË˵ÔÚ³ÌÐòÖмÓÉÏRandomize³õʼ»¯Ëæ»úÖÖ×Ó£¬ÄÇôÕâֻ˵¶ÔÁËÒ»°ë£¬ÔÚ³ÌÐòÖмòµ¥µÄ¼ÓÉÏRandomize£¬ÊÇû×÷Óõģ¬µÀÀíºÜ¼òµ¥£¬Randomize²»¿ÉÄÜÓ°ÏìSQLÓï¾äÖеÄrnd,ÄÇÖ»²»¹ýÊǸö×Ö·û´®£¬SQLÓï¾äÊǷŵ½jetÖÐÈ¥Ö´Ðеġ£
ǰЩÌìÔÚÂÛ̳ÉÏ¿´µ½ÓÐÈË˵ÓÃtime£¬ÄÇôֻÓÃrnd(time)ÕâÑùÊDz»Ðеģ¬rndÖбØÐëÒª°üº¬±íÖеÄÒ»¸ö×Ö¶Î(ÈÎÒâ×ֶΣ¬µ±È»ÊÇÖ÷¼üЧ¹û¸üºÃ)£¬²âÊÔÏÂÀ´£¬rnd(time+id)ÕâÑùÒÀÈ»²»ÐÐ! ²»¹ý·Ç³£ÒâÍâµÄÊÇrnd(time-id)È´³É¹¦ÁË¡£ÎªÊ²Ã´ËµÒâÍ⣬°´ÎÒµÄÀí½â£¬timeÔÚÓëÊýÖµ×öÔËËãʱ£¬»áת»»³ÉÒ»¸öСÓÚ1µÄdouble£¬ÕâÑùÓëID£¨´óÓÚ1µÄÕýÖµ£©×ö¼õÔËËãµÄ½á¹û±ØÈ»ÊÇÒ»¸ö¸ºÊý£¬ÎÒÃÇÖªµÀrndÈç¹ûÓÃÁ˸ºÊýÖÖ×Ó£¬»á²úÉúÏàͬµÄËæ»úÐòÁУ¬ÕâÊÇÎļþ¼Ó½âÃÜËã·¨Öг£Óõ½µÄ·½·¨£¬¿ÉÔÚÕâ¶ùÈ´Äܵõ½ÕýÈ·µÄ½á¹û£¬µ½ÏÖÔÚҲûÏëͨ......
½ÓÏÂÈ¥£¬ÓÃrnd(time-id)¼ÌÐø²âÊÔÄã»á·¢ÏÖ£¬Á¬Ðø¿ìËٵزéѯÏ£¬»áÓÐÎÊÌ⣬»á³öÏÖ¶þ´Î»òÈý´Î²éѯ½á¹ûÒ»ÑùµÄÎÊÌâ¡£·ÖÎöһϿÉÒÔÕÒµ½Ô­Òò£¬rnd(number)ÖеÄnumberÊǸösingle£¬ÕâÑùËü»á½Ø¶Ïtime-idÕâ¸öÔËËã½á¹ûdoubleºóÃæÊý×Ö£¬ÕâÑù¿ìËÙ²éѯʱnumberÕâ¸öֵû¸Ä±ä£¬ËùÒÔ²éѯ½á¹ûҲûÓиı䡣


Ïà¹ØÎĵµ£º

access db

 class Program
    {
        static void Main(string[] args)
        {
            String conStr = "Data Source=mesqas;User ID=ctdsp_oee;Password=12345 ......

C#Á¬½ÓAccessºÍSQL ServerÊý¾Ý¿â

C#Á¬½ÓÁ¬½ÓAccess
Ê×ÏÈ¿´Ò»¸öÀý×Ó´úÂëƬ¶Ï:
³ÌÐò´úÂë:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\BegASPNET\Northwin ......

ÓÃTSQL°ÑAccessµÄ±íµ¼Èëµ½Ô¶³ÌSql Server

ÓÃTSQL°ÑAccessµÄ±íµ¼Èëµ½Ô¶³ÌSql Server£º
°Ñaccess µÄ.mdbÀït_itemList ±íµÄÊý¾Ý²åÈëµ½Ô¶³ÌSqlServerµÄt_itemL1111111±íÀï¡£
SELECT  top 10 *  INTO  t_itemL1111111 IN [ODBC] 
[ODBC;Driver=SQL Server; UID=jyb;PWD=jyb;Server=10.1.18.49;DataBase=ËùÓкϲ¢;]
    &nb ......

½²½âMSSQLÊý¾Ý¿âÖÐSQLËø»úÖƺÍÊÂÎñ¸ôÀ뼶±ð

Ëø»úÖÆ
NOLOCKºÍREADPASTµÄÇø±ð¡£
1. ¿ªÆôÒ»¸öÊÂÎñÖ´ÐвåÈëÊý¾ÝµÄ²Ù×÷¡£
BEGIN TRAN t
INSERT INTO Customer
SELECT 'a','a'
2. Ö´ÐÐÒ»Ìõ²éѯÓï¾ä¡£
SELECT * from Customer WITH (NOLOCK)
½á¹ûÖÐÏÔʾ"a"ºÍ"a"¡£µ±1ÖÐÊÂÎñ»Ø¹öºó£¬ÄÇôa½«³ÉΪÔàÊý¾Ý¡£(×¢:1ÖеÄÊÂÎñδÌá½») ¡£NOLOCK±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ