CREATE PROCEDURE [dbo].[spMRViewToProc]
@FromDbName varchar(50),
@ToDbName varchar(50)
AS
exec( 'SELECT '[email protected]+ '.dbo.materialrequest.*, ISNULL( '[email protected]+ '.dbo.materialrequestContrast.ModifyDate,
'[email protected]+ '.dbo.materialrequest.InputDate) AS ModifyDate INTO #Temp
FROM '[email protected]+ '.dbo.materialrequest LEFT OUTER JOIN
'[email protected]+ '.dbo.materialrequestContrast ON
'[email protected]+ '.dbo.materialrequest.MaterialRequestID = '[email protected]+ '.dbo.materialrequestContrast.MaterialRequestID ')
SELECT * FROM #Temp
GO
(所影响的行数为 24 行)
报错:服务器: 消息 208,级别 16,状态 1,过程 spMRViewToProc,行 10
对象名 '#Temp ' 无效。
请问:这个怎么改??
------解决方案--------------------
CREATE PROCEDURE [dbo].[spMRViewToProc]
@FromDbName varchar(50),
@ToDbName varchar(50)
AS
exec( 'SELECT '[email protected]+ '.dbo.materialrequest.*, ISNULL( '[email protected]+ '.dbo.materialrequestContrast.ModifyDate,
'[email protected]+ '.dbo.materialrequest.InputDate) AS ModifyDate INTO #Temp
FROM '[email protected]+ '.dbo.materialrequest LEFT OUTER JOIN
'[email protected]+ '.dbo.materialrequestContrast ON
'[email protected]+ '.dbo.materialrequest.MaterialRequestID = '[email protected]+ '.dbo.materialrequestContrast.MaterialRequestID SELECT * FROM #Temp ')
GO