R Naamän Villa O
R Naamän Villa O

Reputation: 31

SQL: create table from another WITHOUT populate the new table

Is there a way to create a new table based on an existing one (select) without populating the new table with data from the existing one?

example, this query populates the new table:

CREATE TABLE tempTable NO PARTITION AS 
    ( SELECT 
    TRIM(COMPANY_ID) AS COMPANY_ID 
     FROM
         {schema}.table2
    FOR READ UNCOMMITTED ACCESS IN SHARE MODE );

Thanks.

Upvotes: 0

Views: 68

Answers (1)

Eric
Eric

Reputation: 3257

In SQL Server, you can do

SELECT *
INTO NewTable
FROM OldTable
WHERE 1 = 0

Upvotes: 1

Related Questions