Just a quick question. I have a stored procedure that takes two parameters, a varchar (table name) and a tabletype (range of primary key ID values), and uses them to return all FK connections to and from the table for the provided ID's.
The usage is tricky though, since you actually need to declare the tabletype, select the ID's into it, and then execute the procedure like so:
DECLARE @IDVALS SearchObjRef_Type INSERT INTO @IDVALS SELECT TOP 10 RAND_ID FROM RANDTABLE EXEC usp_SearchObjRef @TABLENAME = 'RANDTABLE', @IDRANGE = @IDVALS
This works just fine, but I'd like to find a more comfortable, fast and easy way to use the procedure in standard selects. What would be the best way, assuming it's even possible, to do all that in one command?
For a logical example that obviously doesn't work, what I'd like to do is a form of the following:
EXEC usp_SearchObjRef @TABLENAME = 'RANDTABLE', @IDRANGE = (SELECT TOP 10 RAND_ID FROM RANDTABLE)