Home Forums SQL Server 2008 SQL Server Newbies How to create a policy that will periodically check the membership of sysadmin? RE: How to create a policy that will periodically check the membership of sysadmin?

  • Now I have another question. I want to check if default port is 1433 or not. If so, when I evaluate the condition I want to see "x" in target details part.. However, I could not create condition, it gives an error "make sure string constants are enclosed in single quotes and facet properties are prefixed with "@" sign." and I can not click "ok".

    How do you think I can solve this problem?

    And here it is the script I've been tring to create condition.

    ExecuteSql('Numeric','declare @Server as varchar(128)

    declare @KeyToInterogate as varchar(200)

    declare @Version as varchar (512)

    declare @PortNumber as varchar(8)

    set @Server = @@ServerName

    set @Version = left(@@Version, 38)

    set @KeyToInterogate = 'SOFTWARE\MICROSOFT\MSSQLSERVER\MSSQLSERVER\SUPERSOCKETNETLIB\TCP'

    if charindex('\',@@ServerName) > 0

    begin

    set @KeyToInterogate = 'SOFTWARE\Microsoft\Microsoft SQL Server\'

    set @KeyToInterogate = @KeyToInterogate + substring(@@ServerName,charindex('\',@@ServerName) + 1,len(@@ServerName) - charindex('\',@@ServerName))

    set @KeyToInterogate = @KeyToInterogate + '\MSSQLServer\SuperSocketNetLib\Tcp'

    end

    exec xp_regread

    @rootkey = 'HKEY_LOCAL_MACHINE',

    @key = @KeyToInterogate,

    @value_name = 'TcpPort',

    @value = @PortNumber output

    select @PortNumber

    ')