[英]How to check if all my SQL Server stored procedures are encrypted or not in one shot?
Is there any way to check whether all my stored procedures are encrypted or not in one shot?有什么方法可以一次检查我所有的存储过程是否都加密了?
I know to view the procedure's definition I get a message telling me that it's encrypted.我知道要查看程序的定义,我会收到一条消息,告诉我它已加密。
EXEC sp_helptext 'StoredProcedureName';
But I have a lot of stored procedures (1000+) so is there a better way to check 1 shot for all the stored procedures?但是我有很多存储过程(1000+),那么有没有更好的方法来检查所有存储过程的 1 个镜头?
You need to check the sys.sql_modules
system view .您需要检查
sys.sql_modules
系统视图。
SELECT
p.name,
IsEncrypted = CAST(CASE WHEN m.definition IS NULL THEN 1 ELSE 0 END AS bit)
FROM sys.procedures p
JOIN sys.sql_modules m ON m.object_id = p.object_id
WHERE m.definition IS NULL
Alternatively, you can check the object property ( kudos to @AaronBertrand )或者,您可以检查 object 属性(感谢@AaronBertrand )
SELECT
name,
IsEncrypted = OBJECTPROPERTY([object_id], 'IsEncrypted')
FROM sys.procedures;
If the question is truly are all the SPs encrypted then the following code will handle it:如果问题确实是所有SP 都加密了,那么下面的代码将处理它:
select case when exists
( select 42 from sys.procedures where ObjectProperty( object_id, 'IsEncrypted' ) = 0 and [type] = 'P' ) then 'No'
else 'Yes' end as AllSPsEncrypted;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.