急,大侠们帮我瞧瞧:存储过程报错(其中有调用别的存储过程)
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[sp_getExpert]
@jibie int,
@chengguo int
AS
BEGIN
DECLARE @renshu int
DECLARE @chaoshi int
DECLARE @tixing VARCHAR(2000)
DECLARE @fig int
DECLARE @wuyong int
DECLARE @Expert varchar(20)
DECLARE @time datetime
declare @xuli varchar(20)
if(@jibie=0)
select @renshu=tejizjrs,@tixing=ShenBaoTXNR,
@chaoshi=ShenBaoCSSX from ChengGuoXTSZ
if(@jibie=1)
select @renshu=gaojizjrs,@tixing=ShenBaoTXNR,
@chaoshi=ShenBaoCSSX from ChengGuoXTSZ
if(@jibie=2)
select @renshu=putongzjrs,@tixing=ShenBaoTXNR,
@chaoshi=ShenBaoCSSX from ChengGuoXTSZ
set @fig=0
--@fig 用于循环时做参数
DECLARE cur_expert CURSOR FOR
SELECT BianHao,(SELECT COUNT(*) AS Expr1 FROM
ChengGuoPS WHERE (ZhuanJiaBH = ZhuanJiaXX.BianHao)) AS quant FROM ZhuanJiaXX
WHERE (ChengGuoLB = 1) and jibie=@jibie ORDER BY quant asc
set @time=DATEADD(dd, @chaoshi, getdate())
OPEN cur_expert
WHILE (@@FETCH_STATUS = 0) and (@fig <@renshu)
BEGIN
FETCH NEXT FROM cur_expert INTO @Expert,@wuyong
--此处取通用序列
EXECUTE @xuli=QAMER_PA.dbo.sp_getSeqNo 'SEQ_ChengGuoPSBH '
--set @xuli=FUNC.sp_getSeqNo( "SEQ_ChengGuoPSBH ")
insert into ChengGuoPS (BianHao,ZhuanJiaBH,YeWuBH,TiXingRQ) values (@xuli,@Expert,@chengguo,@tixing)
set @fig=@fig+1
END
CLOSE cur_expert
DEALLOCATE cur_expert
PRINT 'The indexes on all tables have been rebuilt. '
END
----------
报错内容是:
消息 208,级别 16,状态 6,过程 sp_getExpert,第 53 行
对象名 'dbo.sp_getExpert ' 无效。
------解决方案--------------------在存储过程中调用同一sqlserver 服务器别的数据库QAMER_PA的存储过程
你要确定你有没有条用 QAMER_PA 这个数据库下面存储过程的权限,另外这个sp_getSeqNo是用 dbo 建的吗?
如果一切正常,那么你随便换个数据库执行 exec QAMER_PA.dbo.sp_getSeqNo 看看能不能成功
如果这样都不能成功,那么就是看你权限了,千万注意你的所有者是不是dbo
------解决方案-------------------- 'QAMER_PA.sp_getSeqNo '?
应该是 'QAMER_PA.dbo.sp_getSeqNo '吧
检查存储过程的所有者是不是dbo。