create table from view metadata

Shambhu Rai 1,411 Reputation points
2023-02-02T16:29:45.04+00:00

Hi Expert,

how we can create table from view metadata

create view as select col1 from table 1

how we can create table from above view

tried create table as select * from view

Azure SQL Database
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
SQL Server Integration Services
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
{count} votes

3 answers

Sort by: Most helpful
  1. Alberto Morillo 35,401 Reputation points MVP Volunteer Moderator
    2023-02-02T17:01:11.4+00:00

    Maybe what you need is SELECT INTO to create the table for you.

    SELECT * INTO NewTable
    FROM dbo.View
    

    Refresh SSMS to see your table has been created.

    You can also get the information related to each column of the view by running the following query:

    SELECT * FROM information_schema.columns WHERE table_name = 'VIEW_NAME'
    

  2. Shambhu Rai 1,411 Reputation points
    2023-02-02T18:08:07.3633333+00:00

    suggestion please

    0 comments No comments

  3. LiHongMSFT-4306 31,616 Reputation points
    2023-02-03T03:00:42.0466667+00:00

    Hi @Shambhu Rai

    If you only want the view structure, then try this:

    SELECT * INTO NewTable
    FROM your_view
    WHERE 1=2
    

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.