-1

Suppose I have to two tables, Employees and Departments - both are linked via pk and fk.

I have created a view myview and I want to trigger an event at 12:00 Am and create a new table and copy data from the view into new table.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

3

Assuming there is no table already, you can query directly into the table from the view with this:

SELECT * 
INTO #NEWTABLE
FROM YOURVIEW
dfundako
  • 8,022
  • 3
  • 18
  • 34
0

I believe you can do the following:

CREATE TABLE <table_name> AS ( 
    SELEC * 
    FROM myview 
)
CAllen
  • 856
  • 5
  • 14
  • No, not in SQL Server - this is invalid T-SQL syntax ... – marc_s Oct 21 '15 at 05:04
  • Oh ok then. I'm sorry, I don't know how but I never saw SQL server in the above subject i just saw SQL. the query above by @dfundako should do it though. – CAllen Oct 21 '15 at 05:09