日期:2014-05-17 浏览次数:20541 次
--第一个过程
create PROCEDURE Test1
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
if exists (select * from sys.objects where name='temp1' and type='U')
drop table temp1
select * into temp1 from Account
exec test2
END
GO
--第二个过程
create PROCEDURE test2
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select * from temp1
END
--这样是没问题的
exec Test1
--with transaction version
begin tran
insert into tmptable(..) values(..)
commit
select * from tmptable with (nolock) where ...
--without transaction version
insert into tmptable(..) values(..)
if @@rowcount >0
begin
select * from tmptable with (nolock) where ...
end