The AS clause copies definitions for an existing table or query expression to a new table.
The following table describes the various AS options.
Use this option … | To copy from an existing source table or query expression to a new target table … |
---|---|
AS …WITH NO DATA | the specified column definitions only. |
AS … WITH DATA | the specified column definitions and the data associated with those columns. Note that you cannot create a global temporary table using the WITH DATA option. |
AS … WITH NO DATA AND STATISTICS | the specified column definitions and their statistical histograms. Data is not copied. |
AS … WITH DATA AND STATISTICS | the specified column definitions and their statistical histograms. Data is copied. Use count information is copied when USECOUNT is enabled for the target database. See BEGIN QUERY LOGGING. |
To copy only a subset of the source table and, optionally, its statistics, specify a subquery that selects only those columns desired in the target table. You can also use the subquery option to specify column expressions based on columns in the existing table to define column modifications for the target table. See Using Subqueries To Customize An AS Clause for further information.