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

SQL Server [·Ö²¼Ê½²éѯ/ÊÂÎñ]

·Ö²¼Ê½²éѯ
    OPENROWSET
    ´ÓExcelÈ¡Êý¾Ý
    SELECT * from OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=d:\1.xls',[Sheet1$])
    ´ÓOracleÈ¡Êý¾Ý
    SELECT * from OPENROWSET('MSDAORA.1','NetServiceName';'User';'Password','SELECT * from OracleTalbe')
 
    Linked Server(for Oracle)
    ½¨Á¢Linked Server
    sp_addlinkedserver'Allies', 'Oracle', 'MSDAORA.1', 'NetServiceName'
    OracleµÄLogin
    sp_addlinkedsrvlogin'Allies', FALSE, 'SQLServerLogin', 'OracleUser', 'OraclePassword'
    ´ÓOracle²éѯÊý¾Ý
    SELECT*from OPENQUERY( Allies, 'SELECT * from OracleTalbe')£¬»òÕß
    SELECT*from Allies..OracleUser.OracleTalbe
    ÐÞ¸ÄLinked ServerµÄServer Option
     sp_serveroption'Allies', 'Option Name', 'Option Value'
    ÀýÈç
    sp_serveroption'OraDC', 'rpc out', 'true'
    sp_serveroption'OraDC', 'rpc', 'true'
    ÏòOracle²åÈëÊý¾Ý£¨»¹Ã»ÓÐÓùý£©
    INSERT INTO OPENQUERY(Allies, 'SELECT ... from OracleTalbe WHERE 1=2') VALUES ( ... )
    ɾ³ýLinked Server
    sp_dropserver'Allies', 'droplogins'
 
    ×¢Ò⣺ʹÓÃOPENROWSET¡¢OPENQUERYʱ£¬SQL Server²»¶ÔÌá½»µÄSQLÓï¾ä×öÈκμì²é£¬Ö±½Ó½«Óï¾äÌá½»¸øLinked Server½øÐд¦Àí£»Ê¹ÓÃËIJ¿·ÖÃüÃû·¨Ê±£¬SQL Server¿ÉÄÜ´ÓLinked ServerÉ϶ÁÈ¡±»ÒýÓñíµÄÊý¾Ýµ½SQL Server£¬È»ºóÔÚSQL ServerÉÏÀ´Íê³ÉÆäËü²Ù×÷¡£
 
    ÉèÖÃSQL Serverµ½OracleµÄLinked Server£¬¿É²Î¿¼ÒÔÏÂKBÎÄÕ£º
    How to set up and troubleshoot a linked server to Oracle in SQL Server
    Limitations of Microsoft Oracle ODBC Driver and OLEDB Provider
    Techniques to Debug Connectivity Issues to an Oracle Server Using the ODBC Driver


Ïà¹ØÎĵµ£º

»¹Ô­SQLʧ°Ü

Êý¾Ý¿âÖ´ÐÐexec sp_renamedb 'oldname','newname'Óï¾ä£¬ÖØÃüÃûºó£¬½«Êý¾Ý¿â±¸·ÝÎļþ»¹Ô­Ê±£¬»á³öÏÖ´íÎó£¬Èçͼ
ÒòÊýÊý¾ÝÎļþÓëÊý¾Ý¿âÃû³Æ²»Ò»Ö¡£
½â¾ö·½·¨£º¿ÉÒÔÕÒµ½Êý¾ÝÎļþµÄÃû³Æ£¬½«Êý¾Ý¿â»¹Ô­Ãû³Æ¸úÊý¾Ý¿âÎļþÒ»ÖµÄÃû³Æ£¬´Ëʱ»¹Ô­³É¹¦ºó£¬ÔÙÐÞ¸ÄÊý¾Ý¿âµÄÃû³Æ¡£
×¢£ºÊý¾Ý¿âÖØÃüʱ£¬Ð轫SQL·þÎñÆ÷Í£Ö¹£¬ÖØÃüÃûºóÔÙÖØÐ ......

vb.net Á¬½ÓSQLÊý¾Ý¿â

     'ÔÚÒýÓÃÀïÌí¼ÓADODB
Public vscn As ADODB.Connection
Public SQLString As String
SQLString = "Provider=SQLOLEDB.1;Password=ÃÜÂë;Persist Security Info=True;User ID=ÓÃ" & _
"»§;Initial Catalog=Êý¾Ý¿âÃû;Data Source=·þÎñÆ÷Ãû"
         ......

SQL Server´¥·¢Æ÷´´½¨¡¢É¾³ý¡¢Ð޸ġ¢²é¿´Ê¾Àý½Ì³Ì

Ò»﹕
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì﹐Ëü²»Äܱ»ÏÔʽµØµ÷ÓÃ﹐¶øÊÇÔÚÍù±íÖвåÈë¼Ç¼﹑¸üмǼ»òÕßɾ³ý¼Ç¼ʱ±»×Ô¶¯µØ¼¤»î¡£ËùÒÔ´¥·¢Æ÷¿ÉÒÔÓÃÀ´ÊµÏÖ¶Ô±íʵʩ¸´ÔÓµÄÍê
ÕûÐÔÔ¼`Êø¡£
        
¶þ﹕ SQL
ServerΪÿ¸ö´¥·¢Æ÷¶¼´´½¨ÁËÁ½¸öרÓñí᥮ ......

SQLÑ­»·Óï¾ä

SQLÑ­»·Óï¾ä
declare @i int
set @i=1
while @i<30
begin
insert into test (userid) values(@i)
set @i=@i+1
end
---------------
while Ìõ¼þ
begin
Ö´ÐвÙ×÷
set @i=@i+1
end
WHILE
ÉèÖÃÖظ´Ö´ÐÐ SQL Óï¾ä»òÓï¾ä¿éµÄÌõ¼þ¡£Ö»ÒªÖ¸¶¨µÄÌõ¼þΪÕ棬¾ÍÖظ´Ö´ÐÐÓï¾ä¡£¿ÉÒÔʹÓà BREAK ºÍ CONTI ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ