• [转]SQL SERVER中openrowset与opendatasource的区别


    本文转自:http://blog.sina.com.cn/s/blog_6399df820102vyy8.html

    SQL SERVER中openrowset与opendatasource的区别:
    openrowset
    查询:ok
    select * from openrowset('Microsoft.Jet.OLEDB.4.0', 'Excel 5.0;Database=c:/test.xls;User ID=;Password=;', 'select * from [sheet1$]')
     
    或者:ok
    select * from openrowset('Microsoft.Jet.OLEDB.4.0', 'Excel 5.0;Database=c:/test.xls;User ID=;Password=;', [sheet1$])
     
    插入:ok
    insert openrowset('Microsoft.Jet.OLEDB.4.0', 'Excel 5.0;Database=c:/test.xls;User ID=;Password=;', 'select * from [sheet1$]') select '109','ccc','202'
     
    更新:ok
    update openrowset('Microsoft.Jet.OLEDB.4.0', 'Excel 5.0;Database=c:/test.xls;User ID=;Password=;', 'select * from [sheet1$]') set  a2='bbb',a3=345 where a1= 101
     
    删除:
    不支持
     
     
    opendatasource
    查询:ok
    SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source="c:/test.xls";Extended Properties="Excel 8.0;HDR=yes;IMEX=2;"')...[sheet1$]
     
    插入:ok
    insert  OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=c:/test.xls; Extended Properties="Excel 8.0;HDR=yes;IMEX=2;"')...[sheet1$] select '102','ccc','202'
     
    更新:ok
    update  OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=c:/test.xls;Extended Properties="Excel 8.0;HDR=yes;IMEX=2;"')...[sheet1$] set a2='ddd',a3='203' where a2='ccc'
    对数字字段不支持
     
    删除:
    不支持
     
    1.查询结果与EXCEL单元格的格式有很大关系;
    2.路径中的"/"和""意义相同;
    3.对于Excel里含有诸如'-'之类的特殊字符的工作表,在OPENDATASOURCE中无论如何都无法支持,而openrowset则可解决这个问题
     
    特别注意
     
    Extended Properties='Excel 8.0;HDR=yes;IMEX=1'
    A: HDR ( HeaDer Row )设置
    若指定值为Yes,代表 Excel 档中的工作表第一行是栏位名称
    若指定值為 No,代表 Excel 档中的工作表第一行就是資料了,沒有栏位名称
     
    B:IMEX ( IMport EXport mode )设置
     
    IMEX 有三种模式,各自引起的读写行为也不同,容後再述:
    0 is Export mode  为“汇出模式”,这个模式开启的 Excel 档案只能用来做“写入”用途。
    1 is Import mode  为“汇入模式”,这个模式开启的 Excel 档案只能用来做“读取”用途。
    2 is Linked mode (full update capabilities) 为“连結模式”,这个模式开启的 Excel 档案可同时支援“读取”与“写入”用途。
     
    SQL <wbr>SERVER中openrowset与opendatasource的区别:
  • 相关阅读:
    中国正在消失的老行当
    ie9 scrollbar中hover 高度增高的bug
    (替月光博客备份)百度百科:游荡在中国的窃贼
    严格模式下 W3C Strict 验证的几个注意事项
    [转]滤镜渐变使用 IE浏览器
    1.什么是串口?
    6.串口操作之API篇 GetCommTimeouts SetCommTimeouts
    5.串口操作之API篇 SetupComm GetCommState SetCommState
    TeeChart经验总结 13.Export之2.对象保存
    解决"手机存储暂不能使用""SIM卡存储暂不能使用"
  • 原文地址:https://www.cnblogs.com/freeliver54/p/7878229.html
Copyright © 2020-2023  润新知