復制代碼 代碼如下:
---更新計量點中不存在的數據,將臺帳中的信息轉移到計量點中
insert into MetricPoints (MeterID,MetricPointName,[Description],DepartmentID,MediumID)
(SELECT m.MeterID,m.MetricItems+m.InstallPlace as m_MetricPointName,m.MetricItems,m.DepartmentID,m.MediumID
FROM Meters m WHERE NOT EXISTS (SELECT 1 FROM MetricPoints WHERE MetricPoints.MeterID = m.MeterID ) and m.MediumID =2)
復制代碼 代碼如下:
--b表存在(兩表結構一樣)
insert into b select * from a
復制代碼 代碼如下:
insert into b(col1,col2,col3,col4,...) select col1,col2,col3,col4,... from a where...
復制代碼 代碼如下:
--b表不存在
select * into b from a
//
select (字段1,字段2,...) into b from a
新聞熱點
疑難解答