如何将视图中的所有数据插入至新建的表中
如标题。如何将视图view_customerID中的所有customerID插入至新建的表CusMovieType中的customerID。用的是sql server2008.
------解决方案--------------------lnsert into tb(f1,f2..,fn) se1ect f1,f2,...fn from Viewname
------解决方案--------------------
insert into CusMovieType(customerID)
select customerID from view_customerID
------解决方案----------------------如果customerID不是自增列,直接插入
insert into CusMovieType(customerID)
select customerID from view_customerID
--如果是自增列:
set identity_insert CusMovieType on
insert into CusMovieType(customerID)
select customerID from view_customerID
set identity_insert CusMovieType off
不过这个方法有时候也会失败