[英]Executing a stored procedure to insert records into a table - SQL Server 2000
I'm working in SQL Server 2000. The following query is not working 我正在使用SQL Server2000。以下查询不起作用
declare @TempAccountKey Table (AccKey int,SitName varchar(1000),SitKey int)
insert into @TempAccountKey(AccKey,AccName)
exec [usp_Get_AccountForUser] @UserName
It is throwing the error 它抛出错误
EXECUTE cannot be used as a source when inserting into a table variable. 插入表变量时,不能将EXECUTE用作源。
Any ideas? 有任何想法吗?
#1 #1
The linked server is properly set up. 链接服务器已正确设置。 If i execute the following query
如果我执行以下查询
exec [ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser]
it is showing the error 'Could not find stored procedure'. 它显示错误“找不到存储过程”。
Any ideas? 有任何想法吗?
NLV NLV
Use a temp table instead 改用临时表
CREATE TABLE #TempSiteKey (AccKey int,SitName varchar(1000),SitKey int)
insert into #TempSiteKey (AccKey,AccName)
exec [usp_Get_AccountForUser] @UserName
DROP TABLE #TempSiteKey
And the reason you can't call the procedure is because you've delimited it incorrectly 您无法调用该过程的原因是因为您不正确地分隔了该过程
exec [ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser]
Actually means execute the procedure called 'ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser'. 实际上意味着执行名为“ ABC-SQL-PROD.DBabc.dbo.usp_Get_ABCForUser”的过程。
What you want is: 您想要的是:
exec [ABC-SQL-PROD].[DBabc].[dbo].[usp_Get_ABCForUser]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.