{"id":2285,"date":"2012-09-05T07:03:51","date_gmt":"2012-09-05T07:03:51","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=2285"},"modified":"2015-10-29T10:32:36","modified_gmt":"2015-10-29T10:32:36","slug":"sqlserver%e8%bf%9e%e6%8e%a5mysql","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2012\/09\/05\/sqlserver%e8%bf%9e%e6%8e%a5mysql\/","title":{"rendered":"SqlServer\u8fde\u63a5mysql"},"content":{"rendered":"<p>\u65b9\u6848\u6709\u4e8c\u79cd\uff1a<br \/>\n1\uff0cOPENROWSET<br \/>\nSELECT *<br \/>\nFROM<br \/>\nOPENROWSET(&#39;MSDASQL&#39;,&#39;DRIVER={MySQL ODBC 3.51 Driver};<br \/>\nSERVER=192.168.16.210;PORT=3306;DATABASE=mydb;USER=mas;PASSWORD=123456;<br \/>\nSTMT=set names gb2312;OPTION=2049&#39;,<br \/>\n&#39;select bill_time,mobile,sms_content from tbl_sm_bill_120809;&#39;)<\/p>\n<p>2,\u5efa\u7acb\u94fe\u63a5\u670d\u52a1\u5668\u3002<br \/>\n&nbsp; 1\uff09\u5b89\u88c5<a href=\"http:\/\/www.mysql.com\/downloads\/connector\/odbc\/\">mysql ODBC <\/a><br \/>\n&nbsp; 2) \u914d\u7f6e\u7cfb\u7edfDSN,\u63a7\u5236\u9762\u677f &#8211; \u7ba1\u7406\u5de5\u5177-\u6570\u636e\u6e90 (ODBC)<br \/>\n&nbsp; 3\uff09sqlserver\u4e2d\u589e\u52a0\u94fe\u63a5\u670d\u52a1\u5668\u3002<br \/>\n\u53c2\u8003\uff1a<a href=\"http:\/\/www.ideaexcursion.com\/2009\/02\/25\/howto-setup-sql-server-linked-server-to-mysql\/\">How To Setup SQL Server Linked Server to MySQL<\/a><\/p>\n<p>&nbsp; 4\uff09\u4f7f\u7528\uff1aSELECT * FROM mysqlsms&#8230;tbl_sm_bill_120809<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; \u6216\u8005\uff1aSELECT * FROM OPENQUERY(mysqlsms, &#39;SELECT * FROM tbl_sm_bill_120809;&#39;)<\/p>\n<p>&nbsp; \u5bf9\u4e8emysql\u4e2d\u5217\u662fchar\u578b\u7684\u67e5\u8be2\u4f1a\u62a5\u9519\uff0c\u5982\uff1a<\/p>\n<div>\n\t\u94fe\u63a5\u670d\u52a1\u5668 &#39;cti&#39; \u7684 OLE DB \u8bbf\u95ee\u63a5\u53e3 &#39;MSDASQL&#39; \u8fd4\u56de\u7684\u6570\u636e\u4e0e\u5217 &#39;[MSDASQL].V_Caller&#39; \u6240\u9700\u7684\u6570\u636e\u957f\u5ea6\u4e0d\u5339\u914d\u3002\u6240\u9700\u7684(\u6700\u5927)\u6570\u636e\u957f\u5ea6\u4e3a 60\uff0c\u4f46\u8fd4\u56de\u7684\u6570\u636e\u957f\u5ea6\u4e3a 24\u3002<\/div>\n<div>\n\t&nbsp; \u5904\u7406\u65b9\u6cd5\uff0c\u5728\u67e5\u8be2\u65f6\u8f6c\u6362\u4e00\u4e0b<br \/>\n\t&nbsp;&nbsp;<\/p>\n<div>\n\t\t&nbsp;&nbsp;&nbsp;&nbsp;SELECT TOP 10 *&nbsp;<\/div>\n<div>\n\t\t&nbsp;&nbsp;&nbsp;&nbsp;FROM OPENQUERY(cti, &#39;SELECT cast(tel as char(30)) FROM mytable;&#39;)<\/p>\n<pre class=\"brush:sql;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;\">\r\nINSERT INTO OPENQUERY(Servername,&#39;select * from DBName.tablename WHERE 1=2&#39;) --1=2\u9632\u6b62\u67e5\u8be2\u6574\u4e2a\u8868\r\nSELECT &#39;1&#39;\r\n\r\nSELECT *\r\nFROM OPENQUERY(Servername,&#39;select * from DBName.tablename&#39;)\r\n\r\nUPDATE OPENQUERY(Servername,&#39;select * from DBName.tablename&#39;)\r\nSET colname=&#39;2&#39;\r\nWHERE colname=&#39;1&#39;\r\n\r\nSELECT *\r\nFROM OPENQUERY(Servername,&#39;select * from DBName.tablename&#39;)\r\n<\/pre>\n<\/p><\/div>\n<div>\n\t\t&nbsp;<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6848\u6709\u4e8c\u79cd\uff1a 1\uff0cOPENROWSET SELECT * FROM OPENROWSET(&#39;MSDAS [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2285","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=2285"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2285\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=2285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=2285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=2285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}