2 edited tags
| link
    Became Hot Network Question
1
source | link

SQL Create Script DDL Table from View

How do I script a Create Table DDL for a View?

Example View:

create view dbo.CustomerTransaction
as
select
   cust.CustomerId,    -- this is int
   cust.CustomerName,  -- varchar(25)
   tr.PurchaseAmount   -- decimal(10,2)
from dbo.Customer cust
inner join dbo.Transaction tr
   on cust.CustomerId = tr.TransactionId

Expected Result:

create table dbo.CustomerTransaction
(    
     CustomerId int,
     CustomerName varchar(25),
     PurchaseAmount decimal(10,2)
)