SQL 匯出匯入大全 引

2021-04-17 12:47:16 字數 883 閱讀 6920

/******* 匯出到excel

exec master..xp_cmdshell 'bcp settledb.dbo.shanghu out c:/temp1.xls -c -q -s"gnetdata/gnetdata" -u"sa" -p""'

/*********** 匯入excel

select *

from opendatasource( 'microsoft.jet.oledb.4.0',

'data source="c:/test.xls";user id=admin;password=;extended properties=excel 5.0')...xactions

/*動態檔名

declare @fn varchar(20),@s varchar(1000)

set @fn = 'c:/test.xls'

set @s ='''microsoft.jet.oledb.4.0'',

''data source="'+@fn+'";user id=admin;password=;extended properties=excel 5.0'''

set @s = 'select * from opendatasource ('+@s+')...sheet1$'

exec(@s)

*/select cast(cast(科目編號 as numeric(10,2)) as nvarchar(255))+' ' 轉換後的別名

from opendatasource( 'microsoft.jet.oledb.4.0',

'data source="c:/test.xls";user id=admin;password=;extended properties=excel 5.0')...xactions

SQL語句匯入匯出大全

源 不管是把sql server表的資料插入excel insert into openrowset microsoft.jet.oledb.4.0 excel 5.0 hdr yes database c test.xls test select from t test 還是把excel的資料插入...

匯入匯出大全

一 開啟另乙個資料庫 1.開啟sql server2000的另乙個資料庫的表 1 select from openrowset sqloledb sprogram develop 11111 select from kind 2 select from openrowset sqloledb 190...

SQL Server SQL語句匯入匯出大全

匯出到excel exec master.xp cmdshell bcp settledb.dbo.shanghu out c temp1.xls c q s gnetdata gnetdata u sa p 匯入excel select from opendatasource microsoft....