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)
 Using EXEC('tsql-string')

Author  Topic 

shane
Starting Member

33 Posts

Posted - 2000-10-06 : 10:56:05
Is there a way to execute a SQL statement using EXEC('tsql-string') and return the results to a variable. I have tried many possible combinations for doing this, and have not found a solution. I cannot find any documentation regarding this either. An example of my problem is below.
--------------------------------------------------------------
declare @x int,
@SQL varchar(2000)

--This is built dynamically
set @SQL = 'select count(*) from tblCustomers'

/* I neede the results from the statement below
stores in @x. How?? */

EXEC(@SQL)




   

- Advertisement -