T-SQL: How can you create a table with SELECT?

You can use SELECT INTO. From MSDN:

The SELECT INTO statement creates a new table and populates it with
the result set of the SELECT statement. SELECT INTO can be used to
combine data from several tables or views into one table. It can also
be used to create a new table that contains data selected from a
linked server.

So:

SELECT col1, col2, col3 INTO newTable FROM existingTable;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)