Jarrod Dixon
Jarrod Dixon

Reputation: 15807

SQL Server 2008 Management Studio - Running Parameterized Query

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!

Upvotes: 2

Views: 13428

Answers (2)

Robert Blomstrand
Robert Blomstrand

Reputation: 21

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,,>%'   

Upvotes: 2

Brannon
Brannon

Reputation: 26109

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

Upvotes: 6

Related Questions