Have you look at dynamic SQL: @sql varchar(1000)
@sql = 'CASE @MyParam ' @sql = @sql + 'WHEN 'A' THEN Select ID from MyTable ' @sql = @sql + ' WHEN 'B' THEN Select ID from MyTableTwo ' etc... exec (@sql) http://www.databasejournal.com/features/mssql/article.php/1438931 Maya "Bruce, Rodney S Mr CTR USA AMC" <[EMAIL PROTECTED]> wrote: Brad, I can get a CASE statement to work in a query: Select ID FROM MyTable CASE ID WHEN 2 THEN Order 1 WHEN 3 THEN Order 2 but not with a passed param: CASE @MyParam WHEN 'A' THEN Select ID from MyTable WHEN 'B' THEN Select ID from MyTableTwo WHEN 'C' THEN Select ID from MyTableThree Is that possible. All the examples I can find always have the CASE statement as part of the query. >From http://msdn2.microsoft.com/en-us/library/ms181765.aspx : SELECT FirstName, Lastname, TelephoneNumber, 'When to Contact' = CASE WHEN TelephoneSpecialInstructions IS NULL THEN 'Any time' ELSE TelephoneSpecialInstructions END FROM Person.vAdditionalContactInfo Thanks Rodney ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2960 Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
