如何根据修改日期生成存储过程的脚本?

时间:2013-02-19 12:18:50

标签: sql sql-server sql-server-2008 stored-procedures

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

如何根据修改日期实现这一目标???有人请帮忙

3 个答案:

答案 0 :(得分:1)

试试这个

   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')

答案 1 :(得分: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.

答案 2 :(得分: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] ...