SET FMTONLY (Transact-SQL)SET FMTONLY (Transact-SQL)
SQL Server
Azure SQL Database
Azure Synapse Analytics
Parallel Data Warehouse
メタデータだけをクライアントに返します。Returns only metadata to the client. クエリを実際に実行しなくても、応答の形式をテストすることができます。Can be used to test the format of the response without actually running the query.
注意
この機能は使用しないでください。Do not use this feature. この機能は次の機能に変更されました。This feature has been replaced by the following items:
- sp_describe_first_result_set (Transact-SQL)sp_describe_first_result_set (Transact-SQL)
- sp_describe_undeclared_parameters (Transact-SQL)sp_describe_undeclared_parameters (Transact-SQL)
- sys.dm_exec_describe_first_result_set (Transact-SQL)sys.dm_exec_describe_first_result_set (Transact-SQL)
- sys.dm_exec_describe_first_result_set_for_object (Transact-SQL)sys.dm_exec_describe_first_result_set_for_object (Transact-SQL)
Transact-SQL 構文表記規則
Transact-SQL Syntax Conventions
構文Syntax
SET FMTONLY { ON | OFF }
解説Remarks
FMTONLY
が ON
のとき、行セットは列名と共に返されますが、データ行なしになります。When FMTONLY
is ON
, a rowset is returned with the column names, but without any data rows.
Transact-SQL バッチが解析されるとき、SET FMTONLY ON
からは何の影響も出ません。SET FMTONLY ON
has no effect when the Transact-SQL batch is parsed. 影響は実行時に出ます。The effect occurs during execution run time.
既定値は OFF
です。The default value is OFF
.
アクセス許可Permissions
public ロールのメンバーシップが必要です。Requires membership in the public role.
例Examples
次の Transact-SQL コード例では FMTONLY
が ON
に設定されます。The following Transact-SQL code example sets FMTONLY
to ON
. この設定により、選択した列に関するメタデータ情報のみが SQL Server から返されます。This setting causes SQL Server to return only metadata information about the selected columns. 具体的には、列名が返されます。Specifically, the column names are returned. データ行は返されません。No data rows are returned.
例では、ストアド プロシージャ prc_gm29
の実行で次が返されます。In the example, the test execution of stored procedure prc_gm29
returns the following:
- 複数の行セット。Multiple rowsets.
- その
SELECT
ステートメントの 1 つで、複数のテーブルからの列。Columns from multiple tables, in one of itsSELECT
statements.
SET NOCOUNT ON;
GO
DROP PROCEDURE IF EXISTS prc_gm29;
DROP TABLE IF EXISTS #tabTemp41;
DROP TABLE IF EXISTS #tabTemp42;
GO
CREATE TABLE #tabTemp41
(
KeyInt41 INT NOT NULL,
Name41 NVARCHAR(16) NOT NULL,
TargetDateTime DATETIME NOT NULL DEFAULT GetDate()
);
CREATE TABLE #tabTemp42
(
KeyInt42 INT NOT NULL, -- JOIN-able to KeyInt41.
Name42 NVARCHAR(16) NOT NULL
);
GO
INSERT INTO #tabTemp41 (KeyInt41, Name41) VALUES (10, 't41-c');
INSERT INTO #tabTemp42 (KeyInt42, Name42) VALUES (10, 't42-p');
GO
CREATE PROCEDURE prc_gm29
AS
BEGIN
SELECT * FROM #tabTemp41;
SELECT * FROM #tabTemp42;
SELECT t41.KeyInt41, t41.TargetDateTime, t41.Name41, t42.Name42
FROM
#tabTemp41 AS t41
INNER JOIN #tabTemp42 AS t42 on t42.KeyInt42 = t41.KeyInt41
END;
GO
SET DATEFORMAT mdy;
SET FMTONLY ON;
EXECUTE prc_gm29; -- Returns multiple tables.
SET FMTONLY OFF;
GO
DROP PROCEDURE IF EXISTS prc_gm29;
DROP TABLE IF EXISTS #tabTemp41;
DROP TABLE IF EXISTS #tabTemp42;
GO
/**** Actual Output:
[C:\JunkM\]
>> osql.exe -S myazuresqldb.database.windows.net -U somebody -P secret -d MyDatabase -i C:\JunkM\Issue-2246-a.SQL
KeyInt41 Name41 TargetDateTime
----------- ---------------- -----------------------
KeyInt42 Name42
----------- ----------------
KeyInt41 TargetDateTime Name41 Name42
----------- ----------------------- ---------------- ----------------
[C:\JunkM\]
>>
****/