Not using stored procs.  In SQL Server 2000, you can use UDFs, which will do what you 
need.

----- Original Message -----
From: Tyler Clendenin <[EMAIL PROTECTED]>
Date: Tuesday, August 26, 2003 12:37 pm
Subject: OT: MS-SQL EXEC Statement and subqueries

> This is a multiparter.
> 1.  Given the Statement EXEC('SELECT GetDate()') Returns the current
> datetime.  Now lets say that 'SELECT GetDate()' Is stored in the 
> database in
> the table Temp with an PK of 1.  
> Is there a way to do this:
>    EXEC((SELECT QueryVal FROM Temp WHERE Temp_id = 1))
> Without having to do this:
>    SET @tempVar = (SELECT QueryVal FROM Tests WHERE Test_id = 1)
>    EXEC(@tempVar)
> 
> 2.  If i have a stored procedure which returns an INT can i EXEC 
> the stored
> procedure inside of a subquery.  
> Example:
>    SELECT * FROM MyTable WHERE MyID = (EXEC sp_getID)
> 
> 3.  Could I combine the two ideas above.
> Example:
>    SELECT * FROM MyTable WHERE MyDate = (EXEC((SELECT QueryVal 
> FROM Temp
> WHERE Temp_id = 1)))
> 
> I am asking this because i am trying to build an application to 
> query the
> database and create groupings based on query values and also allow 
> groups to
> include other groups.
> 
> Tyler Clendenin
> GSL Solutions
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Reply via email to