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

SQLServer µ¼Èëµ¼³ö

·         ±¾ÎÄÌÖÂÛÁËÈçºÎͨ¹ýTransact-SQLÒÔ¼°ÏµÍ³º¯ÊýOPENDATASOURCEºÍOPENROWSETÔÚͬ¹¹ºÍÒì¹¹Êý¾Ý¿âÖ®¼ä½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬²¢¸ø³öÁËÏêϸµÄÀý×ÓÒÔ¹©²Î¿¼¡£
 
1. ÔÚSQL ServerÊý¾Ý¿âÖ®¼ä½øÐÐÊý¾Ýµ¼Èëµ¼³ö
(1).ʹÓÃSELECT INTOµ¼³öÊý¾Ý 
    ÔÚSQL ServerÖÐʹÓÃ×î¹ã·ºµÄ¾ÍÊÇͨ¹ýSELECT INTOÓï¾äµ¼³öÊý¾Ý£¬SELECT INTOÓï¾äͬʱ¾ß±¸Á½¸ö¹¦ÄÜ£º¸ù¾ÝSELECTºó¸úµÄ×Ö¶ÎÒÔ¼°INTOºóÃæ¸úµÄ±íÃû½¨Á¢¿Õ±í£¨Èç¹ûSELECTºóÊÇ*, ¿Õ±íµÄ½á¹¹ºÍfromËùÖ¸µÄ±íµÄ½á¹¹Ïàͬ£©£»½«SELECT²é³öµÄÊý¾Ý²åÈëµ½Õâ¸ö¿Õ±íÖС£ÔÚʹÓÃSELECT INTOÓï¾äʱ£¬INTOºó¸úµÄ±í±ØÐëÔÚÊý¾Ý¿â²»´æÔÚ£¬·ñÔò³ö´í£¬ÏÂÃæÊÇÒ»¸öʹÓÃSELECT INTOµÄÀý×Ó¡£
    ¼ÙÉèÓÐÒ»¸ö±ítable1£¬×Ö¶ÎΪf1(int)¡¢f2(varchar(50))¡£
    SELECT * INTO table2 from table1
    ÕâÌõSQLÓïµÄÔÚ½¨Á¢table2±íºó£¬½«table1µÄÊý¾ÝÈ«²¿²åÈëµ½table1Öеģ¬»¹¿ÉÒÔ½«*¸ÄΪf1»òf2ÒÔ±ãÏòÊʵ±µÄ×Ö¶ÎÖвåÈëÊý¾Ý¡£
    SELECT INTO²»½ö¿ÉÒÔÔÚͬһ¸öÊý¾ÝÖн¨Á¢±í£¬Ò²¿ÉÒÔÔÚ²»Í¬µÄSQL ServerÊý¾Ý¿âÖн¨Á¢±í¡£
    USE db1
    SELECT * INTO db2.dbo.table2 from table1
    ÒÔÉÏÓï¾äÔÚÊý¾Ý¿âdb2Öн¨Á¢ÁËÒ»¸öËùÓÐÕßÊÇdboµÄ±ítable2£¬ÔÚÏòdb2½¨±íʱµ±Ç°µÇ¼µÄÓû§±ØÐëÓÐÔÚdb2½¨±íµÄȨÏÞ²ÅÄܽ¨Á¢table2¡£     ʹÓÃSELECT INTOҪעÒâµÄÒ»µãÊÇSELECT INTO²»¿ÉÒÔºÍCOMPUTEÒ»ÆðʹÓã¬ÒòΪCOMPUTE·µ»ØµÄÊÇÒ»×é¼Ç¼¼¯£¬Õ⽫»áÒýÆð¶þÒâÐÔ£¨¼´²»ÖªµÀ¸ù¾ÝÄĸö±í½¨Á¢¿Õ±í£©¡£
(2).ʹÓÃINSERT INTO ºÍ UPDATE²åÈëºÍ¸üÐÂÊý¾Ý
    SELECT INTOÖ»Äܽ«Êý¾Ý¸´ÖƵ½Ò»¸ö¿Õ±íÖУ¬¶øINSERT INTO¿ÉÒÔ½«Ò»¸ö±í»òÊÓͼÖеÄÊý¾Ý²åÈëµ½ÁíÍâÒ»¸ö±íÖС£
    INSERT INTO table1 SELECT * from table2
    »ò
    INSERT INTO db2.dbo.table1 SELECT * from table2
    µ«ÒÔÉϵÄINSERT INTOÓï¾ä¿ÉÄÜ»á²úÉúÒ»¸öÖ÷¼ü³åÍ»´íÎó£¨Èç¹ûtable1ÖеÄij¸ö×Ö¶ÎÊÇÖ÷¼ü£¬Ç¡ÇÉtable2ÖеÄÕâ¸ö×Ö¶ÎÓеÄÖµºÍtable1µÄÕâ¸ö×ֶεÄÖµÏàͬ£©¡£Òò´Ë£¬ÉÏÃæµÄÓï¾ä¿ÉÒÔÐÞ¸ÄΪ
INSERT INTO table1  -- ¼ÙÉè×Ö¶Îf1ΪÖ÷¼ü
  SELECT * from table2 WHERE
    NOT


Ïà¹ØÎĵµ£º

SQLSERVER 2000 convertº¯Êýת»»ÈÕÆÚ¸ñʽ


SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ
2008-01-23 15:47
SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ2008-01-15 15:51SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ
SQL ServerÖÐÎÄ°æµÄĬÈϵÄÈÕÆÚ×Ö¶Îdatetime¸ñʽÊÇyyyy-mm-dd Thh:mm:ss.mmm
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
ÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄܾ­ ......

SqlserverÖÐCompute By×Ó¾äÓ÷¨·ÖÎö

SqlserverÖÐCompute By×Ó¾äÓ÷¨·ÖÎö
2007Äê04ÔÂ20ÈÕ ÐÇÆÚÎå 08:05
ʹÓÃCompute by×Ó¾äºÍÐÐͳ¼Æº¯Êý£¨count,sum,max,avg,minµÈ£©£¬¿ÉÒÔͳ¼ÆÅÅÐòÖнá¹ûÍêÈ«ÏàͬµÄÁУ¬Í³¼ÆÖµ×÷Ϊ²éѯ½á¹ûÒÔ¸½¼ÓÐеÄÐÎʽÏÔʾ£¬
Óï·¨£ºCompute avg|count|max|min|sum by ±í´ïʽ
1¡¢¾ÙÒ»¸öÀý×Ó
±ÈÈçÓÐÒ»¸öÊý¾Ý±í£º±íÃûΪperson,Èý¸ö×ֶηֱð ......

Sqlserver×Ô¶¯±¸·Ý

Ò»¡£SqlServer×Ô¶¯×÷Òµ±¸·Ý
1¡¢´ò¿ªSQL Server Management Studio
2¡¢Æô¶¯SQL Server´úÀí
3¡¢µã»÷×÷Òµ->н¨×÷Òµ
4¡¢"³£¹æ"ÖÐÊäÈë×÷ÒµµÄÃû³Æ
5¡¢Ð½¨²½Ö裬ÀàÐÍÑ¡T-SQL£¬ÔÚÏÂÃæµÄÃüÁîÖÐÊäÈëÏÂÃæÓï¾ä
DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath=replace(@ ......

SQLServerµÄCONVERTº¯Êý½éÉÜ

±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔØÇë±êÃ÷³ö´¦£ºhttp://blog.csdn.net/yf520gn/archive/2008/09/26/2982363.aspx
SELECT * from TB_MILES_CB_ORDER
WHERE convert(varchar(100),ORDER_DATE,102)= £¿
ORDER BY ORDER_NO
SELECT CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
SELECT CONVERT(varchar(100), GETDATE ......

»ñÈ¡sqlserverÖÐÊý¾Ý¿âµ±Ç°Á¬½ÓÊý

ÈçºÎ²é¿´SQL SERVERÊý¾Ý¿âµ±Ç°Á¬½ÓÊý
1.ͨ¹ý¹ÜÀí¹¤¾ß
¿ªÊ¼->¹ÜÀí¹¤¾ß->ÐÔÄÜ£¨»òÕßÊÇÔËÐÐÀïÃæÊäÈë mmc£©È»ºóͨ¹ýÌí¼Ó¼ÆÊýÆ÷Ìí¼Ó SQL µÄ³£ÓÃͳ¼Æ È»ºóÔÚÏÂÃæÁгöµÄÏîÄ¿ÀïÃæÑ¡ÔñÓû§Á¬½Ó¾Í¿ÉÒÔʱʱ²éѯµ½Êý¾Ý¿âµÄÁ¬½ÓÊýÁË¡£²»¹ý´Ë·½·¨µÄ»°ÐèÒªÓзÃÎÊÄÇ̨¼ÆËã»úµÄȨÏÞ£¬¾ÍÊÇҪͨ¹ýWindowsÕË»§µÇ½½øÈ¥²Å¿ÉÒÔÌí¼Ó´Ë¼ÆÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ