Subject: Select in Select
Posted By: Paula222 Post Date: 8/20/2006 4:00:06 PM
Hi ,
i have a table that contains names of other tables - and i want to perform complex select like this one :

alter PROCEDURE SearchByType( @keyword nvarchar(100) , @typeID int)
as
select * from (select type from order_types where order_type_id=@typeID) t

But the problem is that it selects the inner table (the table that contains names of tables) - but i want to select from table that is parameter.
Is there a solution?A

Reply By: David_the_DBA Reply Date: 8/26/2006 11:48:13 AM
Use Dynamic SQL like this

EXEC(@SomeSQLString)

or
exec sp_executesql

David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com

Go to topic 48436

Return to index page 193
Return to index page 192
Return to index page 191
Return to index page 190
Return to index page 189
Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184