Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
djcarpen11
Starting Member
25 Posts |
Posted - 2010-04-30 : 06:30:21
|
| Can some one give me some help on the below? I have set up database auditing and wish to run the ALTER SERVER AUDIT command to reycling the auditfile I'm using, the problem I'm having is passing a variable to it. This is the code I'm trying to run and it errors at the alter server audit comment. DECLARE @AuditID intDECLARE @MaxAuditID intSET @AuditID = (Select MIN(audit_id) FROM sys.server_audits audit)SET @MaxAuditid = (Select MAX(audit_id) FROM sys.server_audits audit)WHILE @AuditID <> @maxauditid +1 IF @AuditID IN (SELECT AUDIT_ID FROM sys.server_audits) BEGINDECLARE @AuditName nvarchar(50)SET @AuditName = (SELECT Name FROM sys.server_audits WHERE audit_id = @AuditID)ALTER SERVER AUDIT @AuditName WITH (STATE = OFF)ALTER SERVER AUDIT @AuditName WITH (STATE = ON) |
|
|
djcarpen11
Starting Member
25 Posts |
Posted - 2010-04-30 : 06:42:13
|
| sorry missed the end of my code! DECLARE @AuditID intDECLARE @MaxAuditID intSET @AuditID = (Select MIN(audit_id) FROM sys.server_audits audit)SET @MaxAuditid = (Select MAX(audit_id) FROM sys.server_audits audit)WHILE @AuditID <> @maxauditid +1 IF @AuditID IN (SELECT AUDIT_ID FROM sys.server_audits) BEGINDECLARE @AuditName nvarchar(50)SET @AuditName = (SELECT Name FROM sys.server_audits WHERE audit_id = @AuditID)Select @AuditNameALTER SERVER AUDIT @AuditName WITH (STATE = OFF)ALTER SERVER AUDIT @AuditName WITH (STATE = ON)SET @AuditID = @AuditID + 1 ENDELSE SET @AuditID = @AuditID + 1 |
 |
|
|
|
|
|