在每条update加上事务处理 BEGIN TRANSACTION

解决方案 »

  1.   

    这样不行,我的sql文件是已经生成了的并且有很多,文件也很大,如果对每个加上事物几乎不可能,还有没有别的方法
    isqlw中有个 -C 的参数 不知道是怎么用的??
      

  2.   

    isqlw Utility
    The isqlw utility (SQL Server Query Analyzer) allows you to enter Transact-SQL statements, system stored procedures, and script files.  You can set up shortcuts or create batch files to launch a preconfigured SQL Server Query Analyzer.Syntax
    isqlw [[-?][-S server][-d database][-E][-U user] [-P password]
        {[-i input_file][-o output_file]}[-F U | A | O]
        [-s “column_separator”][-f file_list]]Arguments
    [-?] 
    Displays usage information. 
    [-S server] 
    Specifies the Microsoft® SQL Server™ installation to which to connect. server is the network name of the server. This option is required if you are executing isqlw from a remote computer on the network. The default is local. 
    [-d database] 
    Issues a USE database statement when isqlw is started. The default is the default database of the user. 
    [-E] 
    Uses a trusted connection instead of requesting a password. 
    [-U user] 
    Is the user login ID. Login IDs are case-sensitive. 
    [-P password] 
    Is the login password. The default is NULL. 
    [-i input_file] 
    Identifies the file that contains a batch of SQL statements or stored procedures. If -i is specified, the output file name must also be specified with -o. When -i and -o options are specified, queries in the input file are executed and results are saved in the output file. No user interface is shown while the queries are executing. When execution is completed, the process exits. 
    [-o output_file] 
    Identifies the file that receives output from isqlw. If file format is not specified with -F, the output file will be of the same type as the input file. 
    [-F U | A | O] 
    Is the file format. Values include Unicode, ANSI, and OEM. If -F is not specified, automatic mode is used (if the file is Unicode signed, the file is opened as Unicode; otherwise, the file is opened as ANSI). 
    [-s “column_separator”] 
    Specifies the column-separator character, which is a blank space by default. To use characters that have special meaning to the operating system (for example, | ; & < >), enclose the character in double quotation s (“). 
    [-f file_list] 
    Loads the files listed into SQL Server Query Analyzer. With the -f option, you can load one or more files (file names separated by single space). If more than one file is specified, files are opened on the same connection context. The file name can include the directory path where the file resides. Wildcard characters (such as C:\Test\*.sql) can be used. 
    Res
    The isqlw utility is started directly from the operating system with the case-sensitive options listed here. After starting, SQL Server Query Analyzer accepts SQL statements and sends them to SQL Server interactively. The results are formatted and displayed on the screen. Use the File/Exit menu option or Alt+F4 to exit from isqlw.If no arguments are specified, isqlw starts SQL Server Query Analyzer and interactively takes the input (server, login, and password). If no valid connection properties are specified (for example, if no trusted connection is specified and the login name is also missing), the normal connection dialog box for SQL Server Query Analyzer appears.SQL Server Query Analyzer uses the ODBC API. The utility uses the Microsoft SQL Server ODBC driver default settings for SQL-92, except for QUOTED_IDENTIFIER. SQL Server Query Analyzer defaults to setting QUOTED_IDENTIFIER OFF. To set the option on, go to the Query\Current Connection Options menu and select Use ANSI quoted identifiers in the General tab. For more information, see Effects of SQL-92 Options.To use isqlw interactively, enter the isqlw command (and any of the options) at a command prompt.Examples
    A. Executing SQL statementsThis example connects to MyServer (pubs database) and executes SQL statements from input_file and stores the results of the execution in output_file.isqlw -S MyServer -d pubs -U sa -P -i input_file -o output_file
    B. Using wildcardsThis example loads all .sql files into SQL Server Query Analyzer.  All connections use Windows NT Authentication and point to the pubs database on the local server.isqlw -d pubs -E -f c:\mssql7\install\*.sql
    C. Loading multiple filesThis example loads two files into SQL Server Query Analyzer.  It uses Windows NT Authentication to connect to the local server.isqlw -d pubs -E -f c:\mssql7\install\instpubs.sql c:\mssql7\install\instcat.sql
    D. Using Unicode filesThis example connects to the pubs database on MyServer using Windows NT Authentication and executes the Input.sql file. The results are saved in the Output.txt file.  The files are opened as Unicode files.isqlw -S MyServer -d pubs -E -i input.sql -o output.txt -FU
      

  3.   

    用isqlw来执行*.sql文件
    isqlw 实用工具(SQL 查询分析器)使您得以输入 Transact-SQL 语句、系统存储过程和脚本文件。通过设置快捷方式或创建批处理文件,可以启动预配置的 SQL 查询分析器。语法
    isqlw
        [-?] |
        [
            [-S server_name[\instance_name]]
            [-d database]
            [-E] [-U user] [-P password]
            [{-i input_file} {-o output_file} [-F {U|A|O}]]
            [-f file_list]
            [-C configuration_file]
            [-D scripts_directory]
            [-T template_directory]
        ]参数-?显示用法信息。-S server_name[\instance_name]:指定要连接到的 Microsoft&reg; SQL Server&#8482; 2000 实例。指定用于连接到该服务器上的 SQL Server 2000 默认实例的 server_name。指定用于连接到该服务器上的 SQL Server 2000 命名实例的 server_name\instance_name。如果未指定服务器,isqlw 将连接到本地计算机上的 SQL Server 默认实例。从网络上的远程计算机执行 isqlw 时,此选项是必需的。-d database当启动 isqlw 时,发出一个 USE database 语句。默认值为用户的默认数据库。-E使用信任连接而不请求密码。-U user用户登录 ID。登录 ID 区分大小写。-P password是登录密码。默认设置为 NULL。-i input_file标识包含一批 SQL 语句或存储过程的文件。必须同时指定 -i 和 -o 选项。如果指定 -i 和 -o 选项,将执行输入文件中的查询,并将结果保存到输出文件中。在查询执行过程中不显示用户接口。当执行完成后,进程退出。-o output_file标识接收来自 isqlw 的输出的文件。必须同时指定 –i 和 –o 选项。如果指定 -i 和 -o 选项,将执行输入文件中的查询,并将结果保存到输出文件中。在查询执行过程中不显示用户接口。当执行完成后,进程退出。如果未使用 -F 指定文件格式,则输出文件使用与输入文件相同的类型。-F {U|A|O}是输入文件和输出文件的格式。值包括 Unicode、ANSI 和 OEM。如果未指定 -F,则使用自动模式(如果文件标为 Unicode 格式,则以 Unicode 格式打开;否则,以 ANSI 格式打开文件)。-f file_list将列出的文件装载到 SQL 查询分析器中。使用 -f 选项,可以装载一个或多个文件(文件名以单个空格分开)。如果指定了多个文件,则以相同的连接上下文将这些文件打开。文件名可以包含该文件所驻留的目录路径。可以使用通配符,如 C:\Test\*.sql 中的星号 (*)。-C configuration_file使用配置文件中指定的设置。其它在命令提示下显式指定的参数将重写相应配置文件中的设置。-D scripts_directory重写在注册表中或在用 –C 指定的配置文件中指定的默认存储脚本目录。该值不保留在注册表或配置文件中。若要在 SQL 查询分析器中查看该选项的当前值,请单击"工具"菜单,然后单击"选项"命令。-T template_directory重写在注册表中或在用 –C 指定的配置文件中指定的默认模板目录。该值不保留在注册表或配置文件中。若要在 SQL 查询分析器中查看该选项的当前值,请单击"工具"菜单,然后单击"选项"命令。
    注释
    有用户界面或没有用户界面时都可使用 isqlw 实用工具。若要在没有用户界面的情况下运行 isqlw,请指定有效登录信息(具有信任连接或有效登录 ID 及密码的 SQL Server 2000 实例)和输入及输出文件。isqlw 将执行输入文件的内容,并将结果保存到输出文件中。
    例:
    isqlw -d pubs -E -f "c:\Program Files\Microsoft SQL Server\MSSQL\Install\instpubs.sql" "c:\Program Files\Microsoft SQL Server\MSSQL\Install\instcat.sql"