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/