SQL SERVER ºÍEXCELµÄÊý¾Ýµ¼Èëµ¼³ö
SQL SERVER ºÍEXCELµÄÊý¾Ýµ¼Èëµ¼³ö
1¡¢ÔÚSQL SERVERÀï²éѯExcelÊý¾Ý:
-- ======================================================
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
ÏÂÃæÊǸö²éѯµÄʾÀý£¬Ëüͨ¹ýÓÃÓÚ Jet µÄ OLE DB Ìṩ³ÌÐò²éѯ Excel µç×Ó±í¸ñ¡£
SELECT *
from OpenDataSource ( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions
-------------------------------------------------------------------------------------------------
2¡¢½«ExcelµÄÊý¾Ýµ¼ÈëSQL server :
-- ======================================================
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
ʵÀý:
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions
-------------------------------------------------------------------------------------------------
3¡¢½«SQL SERVERÖвéѯµ½µÄÊý¾Ýµ¼³ÉÒ»¸öExcelÎļþ
-- ======================================================
T-SQL´úÂ룺
EXEC master..xp_cmdshell 'bcp ¿âÃû.dbo.±íÃûout c:\Temp.xls -c -q -S"servername" -U"sa" -P""'
²ÎÊý£ºS ÊÇSQL·þÎñÆ÷Ãû£»UÊÇÓû§£»PÊÇÃÜÂë
˵Ã÷£º»¹¿ÉÒÔµ¼³öÎı¾ÎļþµÈ¶àÖÖ¸ñʽ
ʵÀý:EXEC master..xp_cmdshell 'bcp saletesttmp.dbo.CusAccount out c:\temp1.xls -c -q -S"pmserver" -U"sa" -P"sa"'
EXEC master..xp_cmdshell 'bcp "SELECT au_fname, au_lname from pubs..authors ORDER BY au_lname" queryout C:\ authors.xls -c -Sservername -Usa -Ppassword'
ÔÚVB6ÖÐÓ¦ÓÃADOµ¼³öEXCELÎļþ´úÂ룺
Dim cn As New ADODB.Connection
cn.open "Driver={SQL Server};Server=WEBSVR;DataBase=WebMis;UID=sa;WD=123;"
cn.execute "master..xp_cmdshell 'bcp "SELECT col1, col2 from ¿âÃû.dbo.±íÃû" queryout E:\DT.
Ïà¹ØÎĵµ£º
ÔÚijЩ³¡ºÏÏ£¬´æ´¢¹ý³Ì»ò´¥·¢Æ÷ÀïµÄSQLÓï¾äÐèÒª¶¯Ì¬Éú³É¡£OracleµÄDBMS_SQL°ü¿ÉÒÔÓÃÀ´Ö´Ðж¯Ì¬SQLÓï¾ä¡£±¾ÎÄͨ¹ýÒ»¸ö¼òµ¥µÄÀý×ÓÀ´Õ¹Ê¾ÈçºÎÀûÓÃDBMS_SQL°üÖ´Ðж¯Ì¬SQLÓï¾ä£º
DECLARE
v_cursor NUMBER;
v_stat NUMBER;
& ......
General Overview
FeatureSQL Server 2008 (RC0)MySQL 5.1/6PostgreSQL 8.3/PostGIS 1.3/1.4
OS
Windows XP, Windows Vista, Windows 2003, Windows 2008
Windows XP, Windows Vista, (haven't tested on 2008), Linux, Unix, Mac
Windows 2000+ (including Vista and 2003, haven't tested on 2008), Linux, Unix, Ma ......
SQL Server 2000 Êý¾Ý¿âͬ²½ÅäÖõÄÔÀí
¸´ÖƵĸÅÄî
Microsoft? SQL Server? 2000 µÄ¸´ÖÆÊÇÔÚÊý¾Ý¿âÖ®¼ä¶ÔÊý¾ÝºÍÊý¾Ý¿â¶ÔÏó½øÐи´ÖÆ
ºÍ·Ö·¢²¢½øÐÐͬ²½ÒÔÈ·±£ÆäÒ»ÖÂÐÔµÄÒ»×é¼¼Êõ¡£
ʹÓø´ÖÆ¿ÉÒÔ½«Êý¾Ý·Ö·¢µ½²»Í¬Î»Öã¬Í¨¹ý¾ÖÓòÍø¡¢Ê¹Óò¦ºÅÁ¬½Ó¡¢Í¨¹ý Internet ·Ö
·¢¸øÔ¶³Ì»òÒƶ¯Óû§¡£¸´ÖÆ»¹Äܹ»Ê¹Óû§Ìá¸ßÓ¦ÓóÌÐòÐÔÄÜ ......
update anketo1 set fb = substring('10',fb+1,1) WHERE id =5
ºóÀ´ÎÊÁËBM,BM˵ֱ½ÓÈ¡·´
update anketo1 set fb = ~ fb WHERE id =5
ÎÒ¸æËßÁËBMÓÃsubstringÒ²¿ÉÒÔ.
BM˵:"Õâ¼Ò»ïÀ÷º¦£¬ÕâÒ²ÄÜÏë³ö,ÕâÊôÓÚаÃÅÎ书."
×îºóÓÖÏëµ½ÓÃABSÈ¡¾ø¶ÔÖµÒ²¿ÉÒÔ
update anketo1 set fb = abs(fb-1)
ÎÒ¾õµÃ²»¹ÜÊÇʲôÎ书,ÄÜÖ ......