Accessing the MS SQL Server database under Linux (turn)

Source: Internet
Author: User
Tags command line mssql mysql sybase sybase client versions port number linux
server| Access | data | Database access to MS SQL Server database under Linux
----Linux as a free Unix-like operating system, with its open source code, multitasking, Xwindow and other features for many users, and many enterprises adopt Linux to A full-featured server (Www,ftp,email, DNS) for its internal network. The intranet of an enterprise is not only to provide access to text information, but also to provide access to information in the Enterprise relational database. SQL Server is used by many enterprises for its low cost, high performance, and efficient integration with NT, but Microsoft does not provide clients under its UNIX, which poses difficulties for such applications 。 This paper presents a solution to this problem. Install the Sybase client----first from the relationship between Microsoft SQL Server and Sybase SQL Server. The two companies have jointly developed the database SQL Server for OS/2 on OS/2, and since then the two companies have independently developed upgrade systems, and Sybase clients can access Microsoft SQL Server. ----compared to other database companies, Sybase is the most benign of Linux, although it does not provide SQL Server under Linux, but provides a free ct-lib client, This may also be one of the reasons many IT managers no longer consider Oracle or Informix when choosing a company database. Now, of course, things have changed. ----Sybase's openclient for Linux is a.out format, which has been converted to elf and dynamic-link elf formats on the Internet, and can be found at the following addresses Load: It is best to download two versions at the same time, normalWhen used dynamically linked versions, but some programs may need a library (LIBBLK.A) at compile time, only included in the Elf. After downloading----, type the following command to expand (assuming the current directory is/usr/tmp):----tar zxvf linuxelfdynamictar.gz----and then move it to the/usr/local mesh Record:----MV sybase/usr/local----compiling and using Sybase clients requires the following settings:----1. Interface file examples are as follows:----MSSQL----Query TCP ether MySQL 1433----wherein: MSSQL is the server name used by the client, then the MSSQL can be referenced; MySQL is the address or name of the server, and if it is the name, the system can find its IP address; 1433 is the port number of SQL Server, and the default value for Microsoft SQL Server is 1433,sybase is 5000. ----2. Sybase environment variables, content is the directory of Sybase clients:----Export sybase=/usr/local/sybase----3. If you compile an example from the Sybase client, you also set the environment variable sybplatform:----export sybplatform=linux----and modify the name of the server in its header file And a description of the user name and password. Using the Sqsh interface to access SQL Server----Sybase clients provide xisql tools, but more people use Sqsh,sqsh is the Sqshell abbreviation, is the improved isql, can be from the next Column address download: The current latest version is 1.6.0. Suppose the downloaded file is placed under the/USR/TMP directory:----tar ZXVF sqsq1.6.0tar.gz----CD sqsh1.6.0----./configure----make;make Install----Then install the resulting executable file Sqsh to/usr/loc The al/bin/directory. The use of----Sqsh is as follows:----# Sqsh--uusername--ppassword--sservername----where username and password are user names and passwords, servername is the name of the server defined in the interface file (for example, MSSQL). ----Sqsh is an interactive command-line interface, commands are executed with input go, and if the command is longer and can be written directly into a few lines, the line can be wrapped in a carriage return. ----The following is an example:----1> use pubs----2> go----1> select * FROM authors----2> go uses ct-lib to write applications---- Sybase Linux clients do not provide db-library, so you should use Ct-library to write applications, using Ct-library to write applications can refer to examples, detailed programming Instructions can refer to Sybase's instructions. Using Sybperl to write applications----Sybperl is a Sybase perl extension that can use the Perl language to access SQL Server, or to write CGI programs. The----Sybperl can obtain from the following address. The current latest version is 2.9.5. ----Get Sybperl Source code expansion, you need to modify the config file, here are a few parameters:----The next file to be modified is PWD, which is used for testing, to The server name, user name, and accountThe order is set to its own configuration. Then compile:----perl; Make test; Make install----The installation is successful, you can use Sybperl to program.    The following is a simple example.    #!/usr/bin/perl use Sybase::ctlib;    $dbh=new sybase::ctlib ' sa ', ', ' MSSQL ';   $DBH->ct_execute ("Select au_id, Au_lname,au_fname from Pubs.dbo.authors"); while ($dbh->ct_results ($restype) = = cs_succeed) {Next unless $dbh (->ct_fetchable); while ($restype, $    au_lname, $au_fname) = $dbh->ct_fetch) {print "$au_id-$au_lname au_fname\n"; ----can see that in just a few lines of statements, you can complete the operation of the database. ----above is a description of accessing the MS SQL Server database under Linux, which introduces basic API programming, Sqsh command line access, and Perl access. In fact, there are other ways to access Linux, such as using the fourth level of JDBC access, when in addition to Java and JDBC, no other software (specific information to access http:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.