日期:2014-05-18 浏览次数:20541 次
declare @saleid int insert into dbo.ss1 select a.,a.,a. from a where 条件a set @saleid=@@IDENTITY if @saleid>0 begin insert into dbo.ss2 select @saleid,a.,a.,a. from a where 条件a end
select a.,a.,a. INTO #T from a where 条件a insert into dbo.ss1 SELECT * FROM #T insert into dbo.ss2 SELECT * FROM #T DROP TABLE #T
------解决方案--------------------
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
------解决方案--------------------