1

我有 50 个存储过程,而我今天只修改了 3 个,我只想为这 3 个修改后的存储过程生成脚本。

我怎样才能根据修改后的日期做到这一点???任何人请帮助

4

3 回答 3

2

尝试这个

   SELECT name , create_date, modify_date ,sm.definition FROM sys.procedures sp
   Inner join sys.sql_modules sm  ON sp.object_id = sm.object_id 
   WHERE CONVERT(DATE,sp.modify_date)    = CONVERT(DATE, '02/19/2013')
于 2013-02-19T12:21:50.347 回答
1

试试这个 - 在 SSMS 中运行“结果到文本”以保留选项卡等。

SELECT      M.definition
FROM        sys.procedures P WITH(NOLOCK)
INNER JOIN  sys.sql_modules M WITH(NOLOCK)
ON          M.object_id = P.object_id
WHERE       P.modify_date >= CAST(GETDATE() AS DATE) -- Modified since midnight today.
于 2013-02-19T12:30:03.307 回答
0

像这样的东西?

select p.name
  ,stuff(m.definition,CHARINDEX('create',m.definition,0),6,'alter') as definition
from sys.procedures p
inner join sys.sql_modules m
on m.object_id = p.object_id
where modify_date >= cast(GETDATE() as date)

结果集就像

name          definition
sp_xxxxxx     alter PROCEDURE [dbo].[sp_xxxxxx] ...
于 2013-02-19T12:33:33.903 回答