允许对系统目录进行临时更新

时间:2019-01-22 10:53:06

标签: sql-server sql-server-2016

我想在RG_SQLLighthouse_DDLTrigger表上禁用/删除此触发器sys.server_triggers

我尝试运行以下两个语句中的任何一个:

update sys.server_triggers set is_disabled = 1 where name = 'RG_SQLLighthouse_DDLTrigger'
delete sys.server_triggers where name = 'RG_SQLLighthouse_DDLTrigger'

但出现以下错误消息

  

不允许对系统目录进行临时更新。

我尝试运行sp_configure 'allow updates', 1,但存在相同的问题。

1 个答案:

答案 0 :(得分:0)

我发现此代码可以完全删除触发器,并且可以正常使用! function debugpdo( $sql=false, $args=array() ){ if( $sql && !empty( $args ) ){ $params = array(); $keys = array(); foreach( $args as $placeholder => $value ){ if( is_numeric( $value ) )$params[]=sprintf('set @%s=%d;',str_replace( ':', '', $placeholder ), $value ); else $params[]=sprintf('set @%s="%s";',str_replace( ':', '', $placeholder), str_replace( '"',"'", $value ) ); $keys[]=str_replace(':','@',$placeholder); } printf( "<pre><h1>Copy & Paste this SQL into mySQL GUI Application</h1>%s\n\n%s;</pre>", implode( PHP_EOL, $params ), str_replace( array_keys( $args ), $keys, $sql ) ); } } $sql = "update `utlansliste` set `username`=:username, `peripherals`=:peripherals, `start_date`=:start_date, `end_date`=:end_date where `id`=:id"; $args = array( ':username' => $username, ':peripherals' => $peripherals, ':start_date' => $start_date, ':end_date' => $end_date, ':id' => $id ); /* To debug the sql, uncomment this and run... */ exit( debugpdo( $sql, $args ) ); /* code continues... */ $stmt = $conn->prepare( $sql ); $result = $stmt->execute( $args );

相关问题