日期:2014-05-19  浏览次数:20508 次

为什么说我的对象已存在?
ALTER   PROCEDURE   [dbo].[testProc]
AS
BEGIN
declare   @test   int;
        select   count(*)   as   c   into   test   from   table2;
print   @test

END

就定义了一个test变量,第一次执行存储过程的时候好的,第二次以后就不行了,说test变量已存在。。为什么?换了其他的变量名同样
我直到零时表可以drop   table,变量怎么办哪?

------解决方案--------------------
ALTER PROCEDURE [dbo].[testProc]
AS
BEGIN
if exists(select 1 from sysobjects where xtype= 'U ' and name= 'test ')
drop table test
declare @test int;
select count(*) as c into test from table2;
print @test

END