create proc proc1(@username varchar(20),@rows int output)
as
SELECT @rows=sum(rows) 
FROM sysindexes a,sysobjects b 
WHERE a.id =b.id AND indid < 2 and b.uid=USER_ID('dbo') and b.xtype='U'---------------------------------
declare @rows int
exec proc1 'dbo',@rows output
select @rows

解决方案 »

  1.   

    create proc proc1(@username varchar(20),@rows int output)
    as
    SELECT @rows=sum(rows) 
    FROM sysindexes a,sysobjects b 
    WHERE a.id =b.id AND indid < 2 and b.uid=USER_ID(@username) and b.xtype='U'GOdeclare @rows int
    exec proc1 'dbo',@rows output
    select @rows
    GO
      

  2.   

    create proc test
    @username varchar(20),
    @rows int output
    as
    SELECT @rows=sum(rowcnt) FROM sysindexes a,sysobjects b 
    WHERE a.id =b.id AND indid < 2 and b.uid=USER_ID(@username) and b.xtype='U'GOdeclare @rows int
    set @rows=0
    exec test 'dbo',@rows output
    select @rows
    GO