简体   繁体   English

如何一次性检查我所有的 SQL 服务器存储过程是否已加密?

[英]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.

相关问题 如果我的所有sql server数据库访问都是通过存储过程完成的 - If all my sql server database access is done thru stored procedures MS SQL Server-如何将所有存储过程从我的机器导出到我的朋友机器? - MS SQL Server - How to export all Stored procedures from my machine to my friends machine? 如何使用SQL Server Management Studio将所有存储过程从一个数据库传输到另一个数据库 - How to transfer all stored procedures from one database to another with SQL Server Management Studio SQL Server:如何从数据库中的所有存储过程中找到特定值? - SQL Server : how can I find the specific value from all stored procedures in my database? Sql Server 中存储过程的有效性检查 - Check Validity of Stored Procedures in Sql Server 如何获取所有 SQL 服务器扩展存储过程的参数列表? - How to get a parameter list for all SQL Server extended stored procedures? 如何拒绝 SQL 服务器中特定用户的所有存储过程? - How to deny all stored procedures to specific user in SQL Server? 如何在SQL Server数据库中一次删除所有存储过程? - How to drop all stored procedures at once in SQL Server database? 如何筛选SQL Server中所有现有存储过程的输出? - How to filter output of all existing stored procedures in SQL Server? 如何统计SQL服务器中一个数据库的所有存储过程? - How to count all stored procedures in the SQL Server for a database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM