SQL Server 2005 - Sysxlogins

  • Hi All,

    I want to write a script which can work on both SQL 2000 and SQL 2005, the SQL 2000 Script is given below

    select @@servername,b.name,a.name

    from master.dbo.spt_values a, master.dbo.sysxlogins b

    where a.low = 0

    and a.type = 'SRV'

    and b.srvid IS NULL

    and a.number & b.xstatus = a.number

    As you know Sysxlogins is not present in SQL Server 2005.

    Please help.

    Thanks in Advance.

    Regards,

    Raj

  • The syslogins view is the common view between them. Otherwise, you need to check the server version and have two distinct code blocks. I have different code blocks in a few of my management procedures that are common between servers where functionality is different between versions.

    Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
    My Blog | Twitter | MVP Profile
    Training | Consulting | Become a SQLskills Insider
    Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]

  • Hi Jonathan,

    Thanks for the reply, but from which table I can find xstatus in SQL Server 2005.

    Regards,

    Raj

  • I don't know of one. The syslogin view has a column for each of the server roles that is a bit field in both 2000 and 2005, so you don't have to do a join to find out what roles a login has been granted.

    Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
    My Blog | Twitter | MVP Profile
    Training | Consulting | Become a SQLskills Insider
    Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]

  • What exactly you want to pull out using this code?

    MJ

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply