--使用语句查看一个存储过程的定义 EXEC sp_helptext 'Auth_BankCardAuthorize' --查询所有存储过程的名称以及定义 SELECT name, definition FROM sys.sql_modules AS m INNER JOIN sys.all_objects AS o ON m.object_id = o.object_id WHERE o.[type] = 'P'
https://www.cnblogs.com/Bokeyan/p/10983221.html
-- 总结 -- 1,查询指定存储过程 SELECT definition FROM sys.sql_modules WHERE object_id=OBJECT_ID('sp_name','P') -- 2,跨库查 SELECT definition FROM db2.sys.sql_modules WHERE object_id=OBJECT_ID('db2.dbo.sp_name','P') -- 3.1,跨服务器查,使用OPENROWSET SELECT definition FROM OPENROWSET(...) a -- 3.2,跨服务器查,使用Linkserver,join系统表指定,不使用系统函数(较复杂)