Import data from SQL Server 2000 to MYSQL5.1. 1. in SQL Server 2000, right-click the database to be exported and choose> all tasks> export data. 2. In the displayed dialog box, select "Next ". ", in the DTS import/export wizard, select "Next" 3. In the next dialog box, change the purpose to "Text File". In the file name dialog box, find the name of the file to be exported, click "Next ". 4. In the displayed dialog box, select "Use a query item to specify the data to be transmitted" and click "Next ". 5. In the displayed dialog box, enter related query statements. (For example, select id, name, pwd from user) Click "analysis". If "SQL statement valid" is displayed, click Next. 6. In the select target file format dialog box, select the corresponding separator (generally comma) and text delimiter (generally double quotation marks {"}), if necessary, click "Convert format" (I have selected to change the type of all fields to varchar, so that you can set delimiter in PHP) www.2cto.com 7. Next-> next-> finish 8. If "one table is successfully copied from Microsoft SQL Server to Flat File" is displayed." The export from SQL Server 2000 is successful! PHP versions must be later than 5.0 <? Php $ mysqli = new mysqli ('localhost', 'root', '000000', 'Douglas '); // This place must be set to utf8 instead of UTF-8 or UTF-8, if it is not utf8, garbled characters will appear in the Data $ mysqli-> query ("set names utf8"); if ($ mysqli) {www.2cto.com $ fh = fopen ('user.txt ', 'R'); $ delimiter = ','; $ enclosure = '"'; while ($ line = fgetcsv ($ fh, 120000, $ delimiter, $ enclosure )) {$ id = $ line [0]; $ name = $ line [1]; // because the text file exported by SQL Server 2000 is GB2312, it must be converted to the same Cha as the table in MYSQL. Racter Set, of course, this location and according to the need, if the table's Character set is GBK, then the UTF-8 of this location must be GBK $ name = iconv ('gb2312', 'utf-8 ', $ name); $ pwd = $ line [2]; $ query = "insert into user (id, name, pwd) values ('$ id',' $ name ', '$ pwd') "; $ result = $ mysqli-> query ($ query);} fclose ($ fh); mysqli_close ();} else {echo "You can't connect! ";}?> Author: DouglasLau