Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to use OpenQuery return values

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-15 : 20:36:48
Jennifer writes "I have an OpenQuery statement - see code below

set @squery = N'Select * From Openquery(CORE, ''select ' + Cast(@CorTrans as varchar(10)) + ' = transactions, ' + cast(@CorSales as varchar(10)) + ' = totalsales from core.amlaptop.dbo.actualday where yearid = ' + cast(@yearid as varchar(4)) + ' and periodid = ' + cast(@periodid as varchar(2)) + ' and dayid = ' + cast(@dayid as varchar(3)) + 'and unitid = ' + cast(@Unit as varchar(4)) + ''')'

exec sp_executeSQL @squery

What I'd like to do is use @CorTrans and @CorSales in calculations once the query has run, but once
"exec sp_executeSQL @squery"
runs, @CorTrans and @CorSales are empty.

Please help me and show what I am doing wrong.

I am using SQL Server 2000 and Windows 2000 Pro. edition.

Thanks!

Jennifer"
   

- Advertisement -