资源描述:
《Microsoft Sql Server2005导入导出语句集锦.pdf》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、/*******导出到excelEXECmaster..xp_cmdshell’bcpSettleDB.dbo.shanghuoutc:temp1.xls-c-q-S"GNETDATA/GNETDATA"-U"sa"-P""’/***********导入ExcelSELECT*FROMOpenDataSource(’Microsoft.Jet.OLEDB.4.0’,’DataSource="c:test.xls";UserID=Admin;Password=;Extendedproperties=Excel5.0’)...xactionsSE
2、LECTcast(cast(科目编号asnumeric(10,2))asnvarchar(255))+’’转换后的别名FROMOpenDataSource(’Microsoft.Jet.OLEDB.4.0’,’DataSource="c:test.xls";UserID=Admin;Password=;Extendedproperties=Excel5.0’)...xactions/**导入文本文件EXECmaster..xp_cmdshell’bcp"dbname..tablename"inc:DT.txt-c-Sservername-Us
3、a-Ppassword’/**导出文本文件EXECmaster..xp_cmdshell’bcp"dbname..tablename"outc:DT.txt-c-Sservername-Usa-Ppassword’或EXECmaster..xp_cmdshell’bcp"Select*fromdbname..tablename"queryoutc:DT.txt-c-Sservername-Usa-Ppassword’导出到TXT文本,用逗号分开execmaster..xp_cmdshell’bcp"库名..表名"out"d:tt.txt"-c
4、-t,-Usa-Ppassword’BULKINSERT库名..表名FROM’c:test.txt’WITH(FIELDTERMINATOR=’;’,ROWTERMINATOR=’n’)--/*dBaseIV文件select*fromOPENROWSET(’MICROSOFT.JET.OLEDB.4.0’,’dBaseIV;HDR=NO;IMEX=2;DATABASE=C:’,’select*from[客户资料4.dbf]’)--*/--/*dBaseIII文件select*fromOPENROWSET(’MICROSOFT.JET.OLED
5、B.4.0’,’dBaseIII;HDR=NO;IMEX=2;DATABASE=C:’,’select*from[客户资料3.dbf]’)--*/--/*FoxPro数据库select*fromopenrowset(’MSDASQL’,’Driver=MicrosoftVisualFoxProDriver;SourceType=DBF;SourceDB=c:’,’select*from[aa.DBF]’)1--*//**************导入DBF文件****************/select*fromopenrowset(’MSD
6、ASQL’,’Driver=MicrosoftVisualFoxProDriver;SourceDB=e:VFP98data;SourceType=DBF’,’select*fromcustomerwherecountry!="USA"orderbycountry’)go/*****************导出到DBF***************/如果要导出数据到已经生成结构(即现存的)FOXPRO表中,可以直接用下面的SQL语句insertintoopenrowset(’MSDASQL’,’Driver=MicrosoftVisualFo
7、xProDriver;SourceType=DBF;SourceDB=c:’,’select*from[aa.DBF]’)select*from表说明:SourceDB=c:指定foxpro表所在的文件夹aa.DBF指定foxpro表的文件名./*************导出到Access********************/insertintoopenrowset(’Microsoft.Jet.OLEDB.4.0’,’x:A.mdb’;’admin’;’’,A表)select*from数据库名..B表/*************导入Ac
8、cess********************/insertintoB表selet*fromopenrowset(’Microsoft.Jet.OLEDB.4.0