由于SQL Server的OSql工具只认ANSI和Unicode, 不认UTF8, 所以尽量把Visual Studio的.sql文件用Unicode保存.
方法是修改SQL模版的encoding, 另存为Unicode格式, 文件模版的位置: \Microsoft Visual Studio 9.0\Common7\Tools\Templates\Database Project Items
CMD.exe不认Unicode? 我的机器上是这样的:(, 只好把所有的.bat改成ANSI
------------------------------------------用脚本重建数据库 RebuildDatabase.bat ------------------------------------------
REM @echo off SET uid=sa SET pwd=sa SET db=YOUR_DATABASE_NAME SET server=. SET workingDrive=E: SET workingPath=YOUR DIR %workingDrive% cd %workingPath% dir *.sql /B sortorder N /s | sort > filelist.txt for /f "tokens=*" %%a in (filelist.txt) do ( osql -S %server% -U %uid% -P %pwd% -d %db% -i "%%a" ) del filelist.txt