开发者

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

开发者 https://www.devze.com 2022-12-18 15:25 出处:网络
I\'m working in SQL Server 2000. The following query is not working declare @TempAccountKey Table (AccKey int,SitName varchar(1000),SitKey int)

I'm working in SQL Server 2000. The following query is not working

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 int开发者_C百科o a table variable.

Any ideas?

#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


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'.

What you want is:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号