繁体   English   中英

执行存储过程以将记录插入表中-SQL Server 2000

[英]Executing a stored procedure to insert records into a table - SQL Server 2000

我正在使用SQL Server2000。以下查询不起作用

declare @TempAccountKey Table (AccKey int,SitName varchar(1000),SitKey int) 
insert into @TempAccountKey(AccKey,AccName) 
exec [usp_Get_AccountForUser] @UserName 

它抛出错误

插入表变量时,不能将EXECUTE用作源。

有任何想法吗?

#1


链接服务器已正确设置。 如果我执行以下查询

exec [ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser]

它显示错误“找不到存储过程”。

有任何想法吗?

NLV

改用临时表

CREATE TABLE #TempSiteKey (AccKey int,SitName varchar(1000),SitKey int) 

insert into #TempSiteKey (AccKey,AccName) 
exec [usp_Get_AccountForUser] @UserName 

DROP TABLE #TempSiteKey

您无法调用该过程的原因是因为您不正确地分隔了该过程

exec [ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser]

实际上意味着执行名为“ ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser”的过程。

您想要的是:

exec [ABC-SQL-PROD].[DBabc].[dbo].[usp_Get_ABCForUser]

暂无
暂无

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

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