首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

帮忙看看存储,及其调用,写的对不对?该怎么处理

2012-01-19 
帮忙看看存储,及其调用,写的对不对???alterprocsp_statistic@comseqint,--公司ID@total_actint0output,@t

帮忙看看存储,及其调用,写的对不对???
alter   proc   sp_statistic
@comseq   int,--公司ID
@total_act   int=0   output,
@total_contact   int=0   output,
@total_oppty   int=0   output
as
declare   @COUNTOPP   nvarchar(10),
@countcon   nvarchar(10),
@countact   nvarchar(10),
@id1     nvarchar(100)
select   @id1=cast(@comseq   as   nvarchar(10))
set   @COUNTOPP=N 'select   @a1=count(1)   from   oppty$   where   comseq=   '+@id1
      exec   sp_executesql   @COUNTOPP   ,N '@a1   int   output ',@total_oppty   output  

  set   @countcon= 'select   @a2=count(1)   from   conmas$   where   comseq=   '+@id1
  exec   sp_executesql   @countcon   ,N '@a2   int   output ',@total_contact   output

set   @countact=N 'select   @a3=count(distinct   comseq   )   from   actrd$   where   comseq=   '+@id1
exec   sp_executesql   @countact   ,N '@a3   int   output ',@total_act   output
--调用是不是这样子的???
declare   @total_act   int,
@total_contact   int,
@total_oppty   int
exec   sp_statistic   23,@total_act   output,
@total_contact     output,
@total_oppty     output
select   @total_act     as   aaa
select   @total_contact   as   bbb
select   @total_oppty   as   ccc
执行后结果都是   NULL,

[解决办法]
declare @COUNTOPP nvarchar(10),
@countcon nvarchar(10),
@countact nvarchar(10),
@id1 nvarchar(100)
-- 字符串,太段,10个字符怎么放的下一条SELECT语句

该成
declare @COUNTOPP nvarchar(4000),
@countcon nvarchar(4000),
@countact nvarchar(4000),
@id1 nvarchar(100)

热点排行