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)
 Returning a value from a query string

Author  Topic 

diegoesp
Starting Member

3 Posts

Posted - 2002-03-18 : 10:35:00
Hi. I have a Store Procedure that does many things, and one of them is creating a query on the fly in a string. After executing that query, i want the resulting value being stored in a string. Something like this:

SET sSQL='SELECT IDContent FROM Contents'

SET @value = sp_executesql sSQL

The problem with the preceding code is that... it doesn't work!! is there some way that i can obtain a value from a previously formed query string? thanks


Jay99

468 Posts

Posted - 2002-03-18 : 10:39:53


use NorthWind
go

create table #tmpEmp (EmployeeID int)
declare @sSQL nvarchar(100)
set @sSQL = 'insert #tmpEmp select employeeid from employees'

exec sp_executesql @sSQL

select * from #tmpEmp
go

drop #tmpEmp
go




Jay
Go to Top of Page

diegoesp
Starting Member

3 Posts

Posted - 2002-03-18 : 10:48:30
Thank you very much!!!

Go to Top of Page
   

- Advertisement -