ubuntuÖÐÁ¬½ÓmssqlÊý¾Ý¿â
»ù±¾ÔÀí
FreeTDSΪLinuxϵͳÌṩÁËTDSÐÒéµÄ¿ªÔ´¿Í»§¶Ë¡£ÓÉÓÚMS SQLºÍSybaseʹÓõÄÇ¡ÊÇTDSÐÒ飬ËùÒÔÔÚLinuxÖпÉÒÔÓÃFreeTDSÁ¬½ÓMS SQL¡£
ÎÒÃÇ¿ÉÒÔÀûÓÃOpenOffice.Org Base¼°Linux ODBCʵÏÖ¿ÉÊÓ»¯µÄÊý¾Ý¿â²é¿´·½Ê½¡£·½±ã¸öÈËÓû§Ê¹ÓÃLinuxÔ¶³Ì¹ÜÀí×Ô¼ºµÄÊý¾Ý¿âϵͳ¡£
ÃüÁîÐз½Ê½Ê¹Ó÷½·¨¼ò½é
°²×°FreeTDSºÍsqsh
Ê×ÏÈ°²×°FreeTDS£¬ÔÚDebian
/Ubuntu
ϵͳÖеݲװ¿ÉÒÔÖ±½Ó°²×°tdsodbc
ºÍsqsh
Èí¼þ°ü¡£Èç¹ûÄãʹÓõķ¢ÐаæûÓÐFreeTDS£¬¿ÉÒÔµ½FreeTDSµÄÍøÕ¾
ºÍsqshµÄÍøÕ¾
ÏÂÔØ°²×°¡£
ÏÖÔھͿÉÒÔÓÃsqsh·ÃÎÊSQL ServerÊý¾Ý¿âÁË£¬×î¼òµ¥µÄʹÓ÷½·¨ÈçÏ£º
sqsh -U Óû§Ãû -P ÃÜÂë -S ·þÎñÆ÷µØÖ·
µÈÒ»»á¶ùÈç¹û³öÏÖ1> £¬¾Í˵Ã÷Á¬½Ó³É¹¦ÁË£¬¿ÉÒÔÊÔ×ÅÊäÈëÈçÏÂÓï¾ä£º
SELECT @@version
go
×¢ÒâÊäÈëgoºó²ÅÖ´ÐÐÓï¾ä¡£
ͼÐνçÃæµÄÁ¬½Ó·½Ê½
°²×°Èí¼þ
ÇëÏÈ°²×°Ç°ÃæÃüÁîÐйÜÀí½çÃæ
ÖÐËù˵µÄFreeTDSºÍsqsh¡£È»ºó°²×°Èí¼þ°üunixodbc-bin
(Debian/Ubuntu)»òµ½unixODBCµÄÍøÕ¾
È¥ÏÂÔØ¡¢°²×°¡£
ÅäÖÃODBC
ÅäÖÃFreeTDS
FreeTDSµÄÅäÖÃÎļþÔÚ/etc/freetds/freetds.conf
£¨»òÕßÀàËƵĵط½£©¡£Óñà¼Æ÷´ò¿ªÕâ¸öÅäÖÃÎļþ£¨ÐèÒªrootȨÏÞ£©£¬²¢Ìí¼ÓÈçÏÂÄÚÈÝ£º
[myTDS]
host = ÄãµÄ·þÎñÆ÷µØÖ·
port = 1433
tds version = 7.0
ODBC
ÔËÐÐODBCConfig
£º
$ sudo ODBCConfig
Drivers±êÇ©Ò³->Add¡£ÔÚ³öÀ´µÄ´°¿ÚÖУ¬NameÌîmyTDS
£¬DriverÌî/usr/lib/odbc/libtdsodbc.so
£¨Èç¹ûÕâ¸öÎļþ²»´æÔÚÇëfind
һϣ©£¬SetupÌî/usr/lib/odbc/libtdsS.so
£¨Èç¹û²»´æÔÚÒ²Çëfind
һϣ©¡£È·¶¨¼´¿É£¨×¢ÒâÈ·¶¨ÊǶԻ°¿ò×óÉϽǵÄÄǸöͼ±ê£©¡£
Ñ¡ÔñSystem DSN
±êÇ©Ò³£¬µãAdd£¬DriverÑ¡¸Õ²Å´´½¨µÄmyTDS
£¬µãOK¡£ÔÚµ¯³öµÄ¶Ô»°¿òµÄÖУ¬nameÌîmssqlTest
£¬PortÌî1433£¬Servername¡¢UID¡¢PWD·Ö±ðΪmyTDS
¡¢Óû§Ãû¡¢ÃÜÂ룬ÇëÈçʵÌîд¡£ÔÙÈ·¶¨¼´¿É¡£
²âÊÔÁ¬½Ó
ʹÓÃisql²âÊÔÁ¬½Ó£º
isql -v mssqlTest Óû§Ãû ÃÜÂë
Á¬½Ó³É¹¦ºó»áÓУº
Connected!
sql-statement
help [tablename]
quit
ʹÓÃOpenOffice.Org Base½øÐйÜÀí
×¼±¸¹¤×÷¾ÍÐ÷ºó£¬´ò¿ªOpenOffice.Org Base£¬ÔÚÊý¾Ý¿âÏòµ¼
ÖУ¬Ñ¡ÔñÁ¬½Óµ½ÏÖÔÚÊý¾Ý¿â
£¬ÔÚÏÂÃæÑ¡ÔñODBC£¬ÊäÈëÊý¾ÝÔ´Ãû³Æ£ºmssqlTest
£¬ÔÙÊäÈëÓû§ÃûµÈÐÅÏ¢¾Í¿ÉÒÔÁË¡£
ʹÓÃOpenOffice.Org Base¿ÉÒԲ鿴±íµÄ½á¹¹¼°±íÖеÄÊý¾Ý£¬Ò²¿É½øÐÐÐ޸ģ¬²»¹ýÈç¹ûÁ¬½Óµ½·þÎñÆ÷µÄËÙ¶ÈÂý£¬OpenOffice»á±È½Ï¿¨¡£
Ïà¹ØÎĵµ£º
ÈçºÎÇå³ýMSSQLÊÂÎñÈÕÖ¾Îļþ
ÈýÖÖ·½·¨£º
1¡¢É¾³ýLOG
1)£º·ÖÀëÊý¾Ý¿âÆóÒµ¹ÜÀíÆ÷££¾·þÎñÆ÷££¾Êý¾Ý¿â££¾ÓÒ¼ü££¾·ÖÀëÊý¾Ý¿â
2)£ºÉ¾³ýLOGÎļþ & ......
/// <summary>
/// ´´½¨Êý¾Ý¿â¡£
/// </summary>
/// <param name="srvName">±íÊ ......
ÔÚselect語¾äÀïÃæ¿ÉÒÔʹÓÃcase來對ij個colmunµÄÖµ進ÐзÖ別處Àí£¬±ÈÈç
select case color
when 1 then 'red'
when 2 then 'green'
when 3 then 'blue'
else 'black'
end as 'colorName',
foodName from foods
Èç¹ûʹÓÃÁËleft joinµÄ時ºò£¬Ä³個columnµÄn ......