insert into select的问题 求大神,很急SQL codedeclare @saleid intinsert intodbo.ss1select a.,a.,a. fr
insert into select的问题 求大神,很急
SQL code
declare @saleid int insert into dbo.ss1 select a.,a.,a. from a where 条件a set @saleid=@@IDENTITY if @saleid>0begin insert into dbo.ss2 select @saleid,a.,a.,a. from a where 条件aend
select a.,a.,a. INTO #Tfrom a where 条件ainsert into dbo.ss1SELECT * FROM #Tinsert into dbo.ss2 SELECT * FROM #TDROP TABLE #T [解决办法]
[解决办法] OUTPUT子句貌似就可以了。
if判断可以去掉。
下面直接
SQL code
insert into dbo.ss2 select @saleid,a.,a.,a. from a where 条件a and @saleid>0 [解决办法] OUTPUT子句参考: http://blog.csdn.net/fan158/article/details/6261963 [解决办法]