select top 1 * into #temp from PO_Detail with(nolock) delete from #temp SET IDENTITY_INSERT #temp ON insert #temp(DetailId,BusinessId,ItemNo,PartNo) exec [proc_GetPoItem] 'P600140427','21' select * from #temp drop table #temp
这段代码主要注意的地方:
1)怎样取得存储过程返回的Table :要求为先定义一个临时表,之后使用插入的方式进行插入,插入的时候必须制定对应的栏位
2)使用懒人方法不想建表,而使用选择的方式来建一个临时表。需要注意一定要用top 1,之后删除内容,使用top 0的话,结构没有选进来,是无法插入数据的
3)定义的 PO_detail表中DetailId栏位是递增的列,必须设定 SET IDENTITY_INSERT #temp ON,否则会保错