简体   繁体   English

无效的对象名称“ dbo.sp_GetCustomerRequestReport”。 执行存储过程时

[英]Invalid object name 'dbo.sp_GetCustomerRequestReport'. when executing the stored procedure

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[sp_GetCustomerRequestReport] 
    @FromDate DATETIME, 
    @ToDate DATETIME, 
    @UserId INT, 
    @LoginUserId INT
AS 
BEGIN
    SELECT
        SU.FullName AS FullName,
        FORMAT(CAST(@FromDate AS DATE), 'dd-MM-yyyy') AS FromDate,
        FORMAT(CAST(@ToDate AS DATE), 'dd-MM-yyyy') AS ToDate 
    FROM
        SecUsers SU 
    WHERE
        SU.UserId = @LoginUserId 
END

When executing the above procedure, SQL Server shows an error 执行上述过程时,SQL Server显示错误

Invalid object name 无效的对象名称

Please provide me statement of executing the above stored procedure. 请提供执行上述存储过程的声明。

Thank you in advance. 先感谢您。

Make sure of the following: 确保以下各项:

  • You are currently connected to the database that has the SP to alter. 您当前已连接到具有更改的SP的数据库。
  • The SP exists (has already been created) and it's on the dbo schema (since you are trying to alter it there). SP存在(已经创建),并且在dbo模式上(因为您试图在那里更改它)。
  • The user that is running the statement has enough privileges to modify it. 运行该语句的用户具有足够的特权来对其进行修改。
  • Check if the "invalid object name" message does not refer to the table being used on the SP definition. 检查“无效对象名称”消息是否未引用SP定义中使用的表。

If you can't find it on the object explorer means that either it hasn't been created, you haven't been granted permission to see it or you are looking in the wrong server, database or schema. 如果您在对象资源管理器中找不到它,则意味着它尚未创建,尚未被授予查看权限,或者您在错误的服务器,数据库或架构中查找。 Try executing the same script but with CREATE instead of ALTER, if it already exists then it should fail. 尝试执行相同的脚本,但是使用CREATE而不是ALTER,如果该脚本已经存在,则它将失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM