Periodically connect SQL Server servers using command-line methods on non-SQL clients

Source: Internet
Author: User
Tags command line microsoft odbc driver for sql server connect odbc sql client time interval

Periodically connect SQL Server servers and simulate user query operations using command-line methods on non-SQL clients, while outputting information content

A very long title, the realization of the function is to try to use Non-human way to simulate people to do one thing, in order to facilitate the record, they output into a file for easy access.

Graphical interface, using Microsoft's own ConnMaker.exe, or a Microsoft Data connection (the system is self-contained, creating a file with a suffix of. udl to experience), and visualizing the operation.

Figure 1 A Visual connection query instance created using ConnMaker.exe

But this time the user's demand is that when they try to connect to the SQL Server cluster, it is only his instance that occasionally fails to connect. To verify that the extranet environment is not the problem of the cluster itself, we need to create a similar environment (a non-native machine client connection) to simulate and record these things.

Using a graphical interface at this time may be too intuitive, so this operation is connected, tested, and exported using a command-line approach.

Similar to other database software providers, Microsoft also provides command-line-based connectivity, which allows you to use the Sqlps command directly for command-line operations in an environment where SQL Server servers are installed, and we also have a solution for the non-SQL client environment where the problem is required. Use sqlcmd.

The software is small and can be downloaded directly from Microsoft's Web site, and Microsoft Command line Utilities for SQL server is the product name for sqlcmd. If an installation fails, install the corresponding new version of ODBC driver: Microsoft ODBC Driver for SQL Server-windows and then try to install SQLCMD, note that the software has 32-bit and 64-bit points, Please download it according to your own machine.

For more detailed instructions on SQLCMD, refer to the official MSDN support: Use the sqlcmd utility

This example uses the system's own authentication (integrated security) to connect the data and query in a specific table in the specified database, returning some query results, using this result to determine whether the connection is interrupted, and whether to complete the normal query.

Set task schedule, write batch process, each day delay a random time (0-59 seconds) to execute, output after viewing the results.

Figure 2 here to set the random delay and time interval of the scheduled task

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

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: info-contact@alibabacloud.com 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.