sql存储过程传入ID集合,和临时表的使用
方式1:
Declare @SQL NVarChar(max)
set @SQL='select *from Loanee as a ApplicationID in ('+@ApplicationIDs+')'
Create table #t2 (ID int ,
OutCashAccountNo nvarchar(50),
OutName nvarchar(50),
InCashAccountNo nvarchar(50),
InName nvarchar(50),
Amount decimal(18,2),
CashType int ,
OutInvestorApplyID int,
InInvestorApplyID int ,
OperateType int,
AddTime datetime
);
insert into #t2 Exec (@SQL)
select * from #t2
方式2:
select * into #t from dbo.Split('12,12,1,2',',')
然后用 临时表 #t 关联 相应的表
select * into #t2 from Loanee as a left join #t b on a.applicationid=b.name
select * from #t2