insert into # select col, max(),sum() from table group by ....是这个意思吗
不是,应该是这样:insert into tba select id , col1 = (case when col1 > 0 then '+' else '-' end) from tbb
一个INSERT语句只能针对一个表,如果要针对多个表需要有多个INSERT语句LZ可以先将结果取到一个临时表在临时表中处理过以后分别插入两个表比如:select [字段1],[字段2]into #tmp from [原表] where 条件insert into [表1]([字段1],[字段2]) select [字段1],[字段2] from #tmp insert into [表2]([字段1],[字段2]) select [字段1],[字段2] from #tmp
一个INSERT语句只能针对一个表,如果要针对多个表需要有多个INSERT语句 LZ可以先将结果取到一个临时表在临时表中处理过以后分别插入两个表 比如: SQL codeselect [字段1],[字段2]into #tmp from [原表] where 条件insert into [表1]([字段1],[字段2]) select [字段1],[字段2] from #tmp insert into [表2]([字段1],[字段2]) select [字段1],[字段2] from #tmp 但是这样子的话还是不能对tmp表中的 每条记录进行处理 在程序中是很容易的事情,SQL不能直接解决这问题啊
用 INSTEAD OF 出发器create trigger trigger_name on table_name instead of insert as beginend
select col, max(),sum()
from table
group by ....是这个意思吗
select id , col1 = (case when col1 > 0 then '+' else '-' end) from tbb
SQL codeselect [字段1],[字段2]into #tmp from [原表] where 条件insert into [表1]([字段1],[字段2]) select [字段1],[字段2] from #tmp insert into [表2]([字段1],[字段2]) select [字段1],[字段2] from #tmp
但是这样子的话还是不能对tmp表中的 每条记录进行处理
在程序中是很容易的事情,SQL不能直接解决这问题啊
INSTEAD OF 出发器create trigger trigger_name on table_name
instead of insert
as
beginend