NOTE 22 Part I EXAM PREPARATION compatibility, but
NOTE 22 Part I EXAM PREPARATION compatibility, but future versions of SQL Server will not support its use. Both ISQL and OSQL provide similar functionality. Both utilities enable users to execute T-SQL statements or batches from a server or workstation and view the results returned. ISQL performs this activity using the near obsolete DB-Library protocol, whereas OSQL uses industry-standard ODBC mechanisms. The OSQL utility is similar to the Query Analyzer in that it executes batches of T-SQL code. The utility is run on the command line. Other than this, the two tools (Query Analyzer and OSQL) perform more or less the same function. OSQL Uses OSQL can be used interactively to execute one or more The question arises, Then why use the OSQL utility? The answer: T-SQL statements, display results in One reason is scheduling. a text window, or save results to a text file. Its primary purpose, how- It is possible to custom-schedule the OSQL utility. Say that ever, is to allow the scheduling of you need to access sales figures on a daily basis. You could extract operations via the operating system data manually every morning using the Query Analyzer, but scheduler, SQL Server scheduler, or this way would be too time consuming and ineffective. Or you any other schedule application pro- could set up a job to automate the process. But the best and vided by a third party. most efficient way would be to query with OSQL and save the results into a text file. You could then use scheduling to make that process automatic. The following represents the options for the OSQL utility: OSQL[-?] | [-L] | [ {{-U login_id [-P password]} | E} [-S server_name[instance_name]][-H wksta_name] [-d db_name][-l time_out][-t time_out][-h headers] [-s col_separator][-w column_width][-a packet_size] [-e][-I][-D data_source_name][-c cmd_end][-q query ] [-Q query ][-n][-m error_level][-r{0|1}] [-i input_file][-o output_file][-p][-b][-u][-R][-O] ] The -L parameter lists the locally configured servers and the names of the servers broadcasting on the network. Use -U to supply a login; if -U is omitted, the Windows login is passed in from environment variables, or alternatively, the operating system. If you omit the -P password option, you are prompted to provide your password. If neither the -U or the -P options are used, SQL Server 2000 attempts to connect using Windows Authentication mode. For more information on the other switches and particular examples, consult SQL Server blogs Online. Figure 1.2 illustrates the OSQL command prompt being used to execute a query that has been stored as a SQL script.
For reliable and cheap web hosting services please check javaweb hosting website.