Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server SQL Server 2008 Management Studio-运行参数化查询_Sql Server_Ssms_Sql Server 2008 - Fatal编程技术网

Sql server SQL Server 2008 Management Studio-运行参数化查询

Sql server SQL Server 2008 Management Studio-运行参数化查询,sql-server,ssms,sql-server-2008,Sql Server,Ssms,Sql Server 2008,我希望能够从SSMS中运行已参数化的查询: select name from aTable where id = @id 我知道其他IDE(例如TOAD)允许参数绑定-这在SSMS 2008中可用吗 谢谢 我认为这是不可能的 在这种情况下,我通常只需在窗口顶部添加以下内容: declare @id int set @id = 10 -- followed by the parameterized query 实际上,我认为2008现在支持初始化: declare @id int = 10

我希望能够从SSMS中运行已参数化的查询:

select name
from aTable
where id = @id
我知道其他IDE(例如TOAD)允许参数绑定-这在SSMS 2008中可用吗


谢谢

我认为这是不可能的

在这种情况下,我通常只需在窗口顶部添加以下内容:

declare @id int
set @id = 10

-- followed by the parameterized query
实际上,我认为2008现在支持初始化:

declare @id int = 10

我通常会在SSMS中使用
CTRL-Shift-M
功能。请参见下面的示例和说明。有点乏味,但嘿,总比什么都没有好

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

是的,这也是我正在做的-我曾希望类似于模板参数绑定功能的东西:)SQLCMD允许您使用参数SQLCMD-E-I restoredb.sql-v root=“c:\myroot”RESTORE DATABASE MyDB FROM DISK='$(root)\MyDB.bak'和REPLACE,将'MyDB_data'移动到'$(root)\MyDB.mdf',继续