views:

1216

answers:

2

I'd like to be able to run an already parameterized query from within the SSMS:

select name
from aTable
where id = @id

I know that other IDEs (e.g. TOAD) allow for parameter binding - is this available in SSMS 2008?

Thanks!

+2  A: 

I don't believe this is possible.

What I usually do in this case is just add the following to the top of the window:

declare @id int
set @id = 10

-- followed by the parameterized query

Actually, I think 2008 supports initialization now:

declare @id int = 10
Brannon
Yeah, that's what I'm doing, too - I had hoped for something along the lines of the Template Parameter binding feature :)
Jarrod Dixon
A: 

I would typically use the CTRL-Shift-M functionality in SSMS. See following example with instructions. Bit tedious but hey, better than nothing.

--===============================================
-- Purpose: Search all objects for specified Text
--===============================================
-- Instructions: CTRL-A + CTRL-Shift-M, enter text
-- to search, click Ok and press F5.
-- To repeat search with other text: CTRL-Z (undo)
-- and then repeat above.
SELECT o.Name AS [Object Name]
,o.xType AS [Object Type]
,s.TEXT AS [Object Text]
FROM sySobjects o,
sysComments s
WHERE o.Id = s.Id
AND TEXT LIKE '%<Text To Search,,>%'

Robert Blomstrand