- 參考
- SQL SERVER ACCESS?EXCEL
- SQL SERVER 2000?DTS??Transact-SQL?Transact-SQL?OpenDataSource?OPENROWSET ??SQL??SQL SERVER?ACCESS?EXCEL??
- ?SQL SERVER ACCESS
- ?
- DTSAccessSQL Server?:
- 1SQL SERVERTools???Data Transformation
- 2Services??? czdImport Data???
- 3Choose a Data Source??Microsoft Access as the Source?.mdb(.mdb)?
- 4Choose a Destination???Microsoft OLE?DB Prov ider for SQL?Server???
- 5Specify Table Copy??Query???Copy tables???
- 6Select Source Tables???Select All?????
- Transact-SQL?
- 1.SQL SERVERaccess:
- -- ======================================================
- SELECT *
- FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
- 'Data Source="c:\DB.mdb";User ID=Admin;Password=')...
- -------------------------------------------------------------------------------------------------
- 2.accessSQL server
- -- ======================================================
- SQL SERVER :
- SELECT *
- INTO newtable
- FROM OPENDATASOURCE ('Microsoft.Jet.OLEDB.4.0',
- 'Data Source="c:\DB.mdb";User ID=Admin;Password=' )...
- -------------------------------------------------------------------------------------------------
- 3.SQL SERVERAccess
- -- ======================================================
- SQL SERVER ?
- insert into OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
- 'Data Source=" c:\DB.mdb";User ID=Admin;Password=')...
- (1,2)
- select 1,2 from sql
- ?
- insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
- 'C:\db.mdb';'admin';'', Test)
- select id,name from Test
- INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'c:\trade.mdb'; 'admin'; '', )
- SELECT *
- FROM sqltablename
- -------------------------------------------------------------------------------------------------
- ?SQL SERVER EXCEL
- 1?SQL SERVERExcel:
- -- ======================================================
- 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?ExcelSQL 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 SERVERExcel
- -- ======================================================
- 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'
- VB6ADOEXCEL?
- 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.xls -c -Sservername -Usa -Ppassword'"
- ------------------------------------------------------------------------------------------------
- 4?SQL SERVERExcel:
- -- ======================================================
- insert into OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
- 'Data Source="c:\Temp.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...table1 (A1,A2,A3) values (1,2,3)
- T-SQL?
- INSERT INTO
- OPENDATASOURCE('Microsoft.JET.OLEDB.4.0',
- 'Extended Properties=Excel 8.0;Data source=C:\training\inventur.xls')...[Filiale1$]
- (bestand, produkt) VALUES (20, 'Test')
- -------------------------------------------------------------------------------------------------
- ??SQL SERVER?ACCESSEXCEL??
- EXEC master..xp_cmdshell 'bcp "select OrderID,ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry from Northwind.dbo.orders" queryout "d:\Oreders.txt" -t"|" -c -q -S"127.0.0.1" -U"sa" -P""'
- SELECT *
- FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="xxxx.xls";Extended Properties="Excel 8.0";IMEX=1;Persist Security Info=False')...[a1$]
2015年7月23日 星期四
SQL SERVER and ACCESS, EXCEL data conversion
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言