首页 > 数据库技术 > 详细

sql存储过程传入ID集合,和临时表的使用

时间:2015-08-12 18:55:21      阅读:181      评论:0      收藏:0      [点我收藏+]

方式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

 

sql存储过程传入ID集合,和临时表的使用

原文:http://www.cnblogs.com/yangjinwang/p/4724993.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!