sql server 存储过程 临时表
现在我有两个表,Class1和Class2,两个表的表结构是类似的,就是表2比表1多了几个字段,我想把表1的数据都导入到表2中,请问这个SP怎么写?(最好能给我写出个大概的代码)
不用存储过程贺凯,直接SQL就可以了。
insert into 表2(col1,col2,col3,col4)
select col1,col2,col3,col4 from 表1
ok了禅如唤橡念。
alt+f1 查看Class1有哪些字段,如果没祥敬有identity字段,那么就好办,全选这肢悄些这段,谨饥慎放到省略号里,一条insert语句就搞定了,不需要存储过程
insert into class2(...) select ... from class1
create procedure ups_insertintoClass2
as
insert into Class2(col1,col2,col3,col4)
select col1,col2,col3,col4 from Class1
vowlvxhkwm3440282771kyfzhqpmwg6783635724很不错哦,你返中可以试下
mkzdvoicks62708687242012-1-9 下午 12:06:38
在SQL SERVER中 select * into #temp from A 就生成一个临时表#temp; 在漏判山存储冲笑过程中也是这样用。
一边一半 yaogogo2010 回答的都对 哈哈 我也没什么好说的了