Transact-SQL 编辑器选项Transact-SQL Editor Options

本主题包含有关 Transact-SQL 编辑器的一些选项的信息。This topic contains information about some of the options of the Transact-SQL Editor. 要设置这些选项,请通过“工具\选项” 菜单导航到“选项” 对话框。To set these options, navigate to the Option dialog through the Tools\Options menu.

查询执行Query Execution

查询结果Query Results

查询执行Query Execution

属性Property 描述Description
SET ROWCOUNTSET ROWCOUNT 默认值为 0,指示 SQL Server 在收到所有结果之前将一直等待结果。The default value of 0 indicates that SQL Server will wait for results until all results are received. 如果希望 SQL Server 在获取指定数目的行后暂停查询,请提供一个大于 0 的值。Provide a value greater than 0 if you want SQL Server to halt the query after obtaining the specified number of rows. 若要关闭此选项(以便返回所有的行),请将 SET ROWCOUNT 指定为 0。To turn this option off (so that all rows are returned), specify SET ROWCOUNT 0.
SET TEXTSIZESET TEXTSIZE 默认值为 2,147,483,647 个字节,表示 SQL Server 将针对 text、ntext、nvarchar(max) 和 varchar(max) 数据字段提供最高上限的数据。The default value of 2,147,483,647 bytes indicates that SQL Server will provide a complete data field up to the limit of text, ntext, nvarchar(max), and varchar(max) data fields. 它将不影响 XML 数据类型。It does not affect the XML data type. 提供较小的数值,可以在存在大量值时限制结果数量。Provide a smaller number to limit results in the case of large values. 超出指定数量的列将被截断。Columns greater than the number provided will be truncated.
执行超时值Execution time-out 指示在取消查询之前等待的秒数。Indicates the number of seconds to wait before canceling the query. 值 0 指示无限期的等待或无超时。A value of 0 indicates an infinite wait, or no time-out.
默认情况下,在 SQLCMD 模式下打开新查询 By default, open new queries in SQLCMD Mode 选中此复选框可在 SQLCMD 模式下打开新查询。Select this check box to open new queries in SQLCMD mode. 只有从“工具”菜单打开该对话框时,此复选框才可见。This check box is visible only when the dialog box is opened through the Tools menu.

选择此选项时,请记住下列限制:When you select this option, be aware of the following limitations:

- 数据库引擎查询编辑器中的 IntelliSense 处于关闭状态。- IntelliSense in the Database Engine Query Editor is turned off.
- 由于查询编辑器不能从命令行运行,因此不能传入命令行参数(如变量)。- Because Query Editor does not run from the command line, you cannot pass in command-line parameters such as variables.
- 由于查询编辑器无法响应操作系统提示,因此一定要记住不要运行交互式语句。- Because Query Editor cannot respond to operating-system prompts, you must be careful not to run interactive statements.
SET NOCOUNTSET NOCOUNT 阻止在结果中返回消息,该消息指示 Transact-SQL 语句影响的行数。Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results. 有关更多信息,请参见 SET NOCOUNTFor more information, see SET NOCOUNT.
SET NOEXECSET NOEXEC 为 ON 时,告知 Microsoft® SQL Server™ 编译每批 Transact-SQL 语句但是不执行它们。When ON, tells Microsoft® SQL Server™ to compile each batch of Transact-SQL statements but not to execute them. 为 OFF 时,告知 Microsoft® SQL Server™ 在编译后执行所有批。有关详细信息,请参阅 SET NOEXECWhen OFF, tells Microsoft® SQL Server™ to execute all batches after compilation.For more information, see SET NOEXEC.
SET PARSEONLYSET PARSEONLY 检查每个 Transact-SQL 语句的语法并返回任何错误消息,但不编译或执行语句。Checks the syntax of each Transact-SQL statement and returns any error messages without compiling or executing the statement. 有关更多信息,请参见 SET PARSEONLYFor more information, see SET PARSEONLY.
SET CONCAT_NULL_YIELDS_NULLSET CONCAT_NULL_YIELDS_NULL 控制是将串联结果视为 null 值还是空字符串值。有关详细信息,请参阅 SET CONCAT_NULL_YIELDS_NULLControls whether or not concatenation results are treated as null or empty string values.For more information, see SET CONCAT_NULL_YIELDS_NULL.
SET ARITHABORTSET ARITHABORT 在查询执行过程中发生溢出或被零除错误时终止查询。Terminates a query when an overflow or divide-by-zero error occurs during query execution. 有关详细信息,请参阅 SET ARITHABORTFor more information, see SET ARITHABORT.
SET SHOWPLAN_TEXTSET SHOWPLAN_TEXT 使 Microsoft® SQL Server™ 不执行 Transact-SQL 语句,Causes Microsoft® SQL Server™ not to execute Transact-SQL statements. 而是由 SQL Server 返回有关如何执行语句的详细信息。Instead, SQL Server returns detailed information about how the statements are executed. 有关详细信息,请参阅 SET SHOWPLAN_TEXTFor more information, see SET SHOWPLAN_TEXT.
SET STATISTICS TIMESET STATISTICS TIME 显示分析、编译和执行各语句所需的毫秒数。Displays the number of milliseconds required to parse, compile, and execute each statement.
SET STATISTICS IOSET STATISTICS IO 使 Microsoft® SQL Server™ 显示有关由 Transact-SQL 语句生成的磁盘活动量的信息。Causes Microsoft® SQL Server™ to display information regarding the amount of disk activity generated by Transact-SQL statements.
SET TRANSACTION ISOLATION LEVELSET TRANSACTION ISOLATION LEVEL 控制一个连接所发出的所有 Microsoft® SQL Server™ SELECT 语句的默认事务锁定行为。Controls the default transaction locking behavior for all Microsoft® SQL Server™ SELECT statements issued by a connection. 有关更多信息,请参见 SET TRANSACTION ISOLATION LEVELFor more information, see SET TRANSACTION ISOLATION LEVEL.
SET LOCK_TIMEOUTSET LOCK_TIMEOUT 指定语句等待锁释放的毫秒数。Specifies the number of milliseconds that a statement waits for a lock to be released. 有关详细信息,请参阅 SET LOCK_TIMEOUTFor more information, see SET LOCK_TIMEOUT
SET QUERY_GOVERNOR_COST_LIMITSET QUERY_GOVERNOR_COST_LIMIT 覆盖当前为当前连接所配置的值。Overrides the currently configured value for the current connection. 有关详细信息,请参阅 SET QUERY_GOVERNOR_COST_LIMITFor more information, see SET QUERY_GOVERNOR_COST_LIMIT.
SET ANSI_DEFAULTSSET ANSI_DEFAULTS 控制一组用来共同指定某些 SQL-92 标准行为的 Microsoft® SQL Server™ 设置。Controls a group of Microsoft® SQL Server™ settings that collectively specify some SQL-92 standard behavior. 有关详细信息,请参阅 SET ANSI_DEFAULTSFor more information, see SET ANSI_DEFAULTS.
SET QUOTED_IDENTIFIERSET QUOTED_IDENTIFIER 使 Microsoft® SQL Server™ 遵从关于引号分隔标识符和文字字符串的 SQL-92 规则。Causes Microsoft® SQL Server™ to follow the SQL-92 rules regarding quotation mark delimiting identifiers and literal strings. 由双引号分隔的标识符可以是 Transact-SQL 保留关键字,也可以包含 Transact-SQL 标识符语法规则通常不允许的字符。有关更多信息,请参阅 SET QUOTED_IDENTIFIERIdentifiers delimited by double quotation marks either can be Transact-SQL reserved keywords or can contain characters not usually allowed by the Transact-SQL syntax rules for identifiers.For more information, see SET QUOTED_IDENTIFIER.
SET ANSI_NULL_DFLT_ONSET ANSI_NULL_DFLT_ON 数据库的 ANSI null default 选项为 false 时,更改会话行为以覆盖新列的默认为 null 性。Alters the session's behavior to override default nullability of new columns when the ANSI null default option for the database is false. 有关详细信息,请参阅 SET ANSI_NULL_DFLT_ONFor more information, see SET ANSI_NULL_DFLT_ON.
SET IMPLICIT_TRANSACTIONSSET IMPLICIT_TRANSACTIONS ON时,将连接设置为隐式事务模式。When ON, sets the connection into implicit transaction mode. OFF时,则使连接恢复为自动提交事务模式。When OFF, returns the connection to autocommit transaction mode. 有关详细信息,请参阅 SET IMPLICIT_TRANSACTIONSFor more information, see SET IMPLICIT_TRANSACTIONS.
SET CURSOR_CLOSE_ON_COMMITSET CURSOR_CLOSE_ON_COMMIT 控制在提交事务时是否关闭游标。Controls whether or not a cursor is closed when a transaction is committed. 有关详细信息,请参阅 SET CURSOR_CLOSE_ON_COMMITFor more information, see SET CURSOR_CLOSE_ON_COMMIT.
SET ANSI_PADDINGSET ANSI_PADDING 对列存储值长度小于列的定义大小的值以及在 charvarcharbinaryvarbinary 数据中含有尾随空格的列存储值的方式进行控制。Controls the way the column stores values shorter than the defined size of the column and the way the column stores values that have trailing blanks in char, varchar, binary, and varbinary data. 有关详细信息,请参阅 SET ANSI_PADDINGFor more information, see SET ANSI_PADDING.
SET ANSI_WARNINGSSET ANSI_WARNINGS 为多个错误条件指定 SQL-92 标准行为。有关详细信息,请参阅 SET ANSI_WARNINGSSpecifies SQL-92 standard behavior for several error conditions.For more information, see SET ANSI_WARNINGS.
SET ANSI_NULLSSET ANSI_NULLS 指定在与 null 值一起使用等于 ( =) 和不等于 ( <>) 比较运算符时采用符合 SQL-92 标准的行为。有关详细信息,请参阅 SET ANSI_NULLSSpecifies SQL-92 compliant behavior for the Equals (=) and Not Equal to (<>) comparison operators when they are used with null values.For more information, see SET ANSI_NULLS.

查询结果Query Results

属性Property 描述Description
在结果集中包括查询 Include the query in the result set 将查询文本作为结果集的一部分返回。Returns the text of the query as part of the result set.
复制或保存结果时包括列标题 Include column headers when copying or saving the results 将结果复制到剪贴板或保存到文件时,包括列标题。Include column headers (titles) when results are copied to the clipboard, or saved in a file. 如果希望保存或复制的结果数据只有数据而没有列标题,请清除此复选框。Clear this check box if you do not want saved or copied result data to have only the data, and not the column headings.
执行后放弃结果 Discard results after execution 当屏幕显示接收到查询结果之后,通过放弃查询结果来释放内存。Free memory by discarding the query results after the screen display has received them.
在单独选项卡中显示结果 Display results in a separate tab 在新文档窗口中显示结果集,而不是在查询文档窗口的底部显示。Display the result set in a new document window, instead of at the bottom of the query document window.
执行查询后切换到“结果”选项卡 Switch to results tab after the query executes 自动将屏幕焦点设置到结果集。Automatically set the screen focus to the result set.
检索的最多字符数 Maximum Characters Retrieved 非 XML 数据:Non XML data:

输入一个介于 1 到 65535 之间的数字以指定每个单元中显示的最大字符数。Enter a number from 1 through 65535 to specify the maximum number of characters that will be displayed in each cell. 注意: 指定大量字符可能会导致结果集中显示的数据截断。Note: Specifying a large number of characters may cause data in the result set to appear truncated. 每个单元中显示的最大字符数取决于字号。The maximum number of characters displayed in each cell is dependent on the font size. 在返回较大的结果集时,如果此框中的值太大,可能会导致 SQL Server Management Studio 运行时内存不足,从而影响系统性能。When large result sets are returned, a high value in this box can cause SQL Server Management Studio to run low on memory and hinder system performance.

XML 数据:XML data:

选择 1 MB、2 MB 或 5 MB。Select 1 MB, 2 MB, or 5 MB. 选择“无限制”将检索所有字符。Select Unlimited to retrieve all characters.
输出格式Output format 默认情况下,将在通过用空格分隔结果而得到的列中显示输出。By default the output is displayed in columns created by padding the results with spaces. 您还可以使用逗号、制表符或空格来分隔列。Other options are using commas, tabs, or spaces to separate columns. 选中 “自定义分隔符” 复选框,可以在 “自定义分隔符” 框中指定其他分隔字符。Select the Custom delimiter check box to specify a different delimiting character in the Custom delimiter box.
自定义分隔符Custom delimiter 自行指定用于分隔列的字符。Specify the character of your choice to separate columns. 只有在 “输出格式” 框中选中 “自定义分隔符” 复选框时,才可使用此选项。This option is available only if the Custom delimiter check box is selected in the Output format box.
在结果集中包括列标题 Include column headers in the result set 如果不希望每列都带有列标题,请清除此复选框。Clear this check box if you do not want each column labeled with a column title.
接收到结果时滚动 Scroll as results are received 选中此复选框将使得结果集的显示侧重于结尾处最近返回的记录。Select this check box to keep the display focus on the most recently returned records at the bottom. 清除此复选框,则使其侧重于接收到的前几行。Clear this check box to keep the display focus on the first rows received.
右对齐数值 Right align numeric values 选中此复选框可以将数值与列的右侧对齐。Select this check box to align numeric values to the right of the column. 此选项可以更方便地查看具有固定小数位数的数值。This option can make it easier to review numbers with a fixed number of decimal places.
在执行查询后放弃结果 Discard result after query executes 当屏幕显示接收到查询结果之后,通过放弃查询结果来释放内存。Frees memory by discarding the query results after the screen display has received them.
在单独选项卡中显示结果 Display results in a separate tab 选中此复选框可在新文档窗口中显示结果集,而不是在查询文档窗口的底部显示。Select this check box to display the result set in a new document window instead of at the bottom of the query document window.
执行查询后切换到“结果”选项卡 Switch to results tab after the query executes 单击此项可将屏幕焦点自动设置到结果集。Click to automatically set the screen focus to the result set.
每列中显示的最大字符数 Maximum number of characters displayed in each column 此值默认为 256。This value defaults to 256. 增大此值可显示更大的结果集,而不会将其截断。Increase this value to display larger result sets without truncation.
重置为默认值 Reset to Default 将此页上的所有值重置为原始默认值。Resets all values on this page to the original default values.