创建存储过程后查询创建的table,returns 'Invalid object name' 即使存储过程创建成功
After creating a stored procedure and querying the table created,returns 'Invalid object name' even after successful creation of the stored procedure
我已经编写并通过查询成功创建了一个存储过程
CREATE PROCEDURE [dbo].[Table_Load]
AS
BEGIN
SET NOCOUNT ON
DECLARE @Row_Count_Inserted BIGINT
DROP TABLE IF EXISTS DBB.dbo.Table;
SELECT *
INTO DBB.dbo.Table
FROM
(SELECT *
FROM DBB.dbo.customer_table) y
SET @Row_Count_Inserted = @@RowCount
SELECT @Row_Count_Inserted Row_Count_Inserted
END
这表明存储过程已创建并存在于数据库中。但是当我查询 table 'Table' 使用
SELECT * FROM DBB.dbo.Table
我收到一个错误
Invalid object name
我该如何解决这个问题?我也刷新了数据库,但是还是不行。
您的程序已大大简化,删除了很多额外的代码。假设你有 table customer_table 这会很好用。
CREATE or alter PROCEDURE [dbo].[Table_Load] As
Begin
SET NOCOUNT ON
drop table If Exists dbo.MyTable;
Select *
into MyTable
from customer_table
select Row_Count_Inserted = @@RowCount
End
GO
exec Table_Load
GO
select * from MyTable
我已经编写并通过查询成功创建了一个存储过程
CREATE PROCEDURE [dbo].[Table_Load]
AS
BEGIN
SET NOCOUNT ON
DECLARE @Row_Count_Inserted BIGINT
DROP TABLE IF EXISTS DBB.dbo.Table;
SELECT *
INTO DBB.dbo.Table
FROM
(SELECT *
FROM DBB.dbo.customer_table) y
SET @Row_Count_Inserted = @@RowCount
SELECT @Row_Count_Inserted Row_Count_Inserted
END
这表明存储过程已创建并存在于数据库中。但是当我查询 table 'Table' 使用
SELECT * FROM DBB.dbo.Table
我收到一个错误
Invalid object name
我该如何解决这个问题?我也刷新了数据库,但是还是不行。
您的程序已大大简化,删除了很多额外的代码。假设你有 table customer_table 这会很好用。
CREATE or alter PROCEDURE [dbo].[Table_Load] As
Begin
SET NOCOUNT ON
drop table If Exists dbo.MyTable;
Select *
into MyTable
from customer_table
select Row_Count_Inserted = @@RowCount
End
GO
exec Table_Load
GO
select * from MyTable