#title OpenQuery 예제 [[TableOfContents]] 조낸 까먹어.. ㅡㅡ;; ==== MySQL 연결하기 ==== {{{ --연결된 서버: 192.168.0.1 --공급자: Microsoft OLE DB Provider for ODBC Dirvers --제품이름: MySQL --공급문자열: DRIVER={MySQL ODBC 3.51 Driver}; SERVER=192.168.11.161;Port=3306; DATABASE=ranking; USER=아이디; PASSWORD=패스워드 EXEC master.dbo.sp_addlinkedserver @server = N'192.168.0.1' , @srvproduct=N'MySQL' , @provider=N'MSDASQL' , @provstr=N'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=192.168.11.161;Port=3306; DATABASE=ranking; USER=아이디; PASSWORD=패스워드' --, @provstr=N'DRIVER={MySQL ODBC 3.51 Driver}; SERVER=192.168.11.161;Port=3306; DATABASE=ranking; USER=아이디; PASSWORD=패스워드' EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'192.168.0.1' , @useself=N'False' , @locallogin=NULL , @rmtuser=NULL , @rmtpassword=NULL }}} ==== 예제 ==== {{{ set @seq = (select convert(varchar(50), isnull(max(seq), 0)) from dbo.id where tbl_type = 'a') set @sql = ' select seq , id , ''a'' tbl_type from openquery([192.168.0.1], '' select seq , id from main.id_a where seq > ' + @seq + ''')' }}} ==== 참고자료 ==== * [http://www.sqlleader.com/mboard.asp?exec=view&strBoardID=SS2005TSQL&intSeq=1124 데이터를 SQL Server로 가져오기 위한 여러 방법들]