function that returns version of operating system

  • Is there a system function in SQL or VB that returns the operating system of the PC the user is login, that is, windows 98, windows 2000 and so on ?

    Thanks

  • sql version in red, Os version in BLue

    select @@version

    Returns

    Microsoft SQL Server  2000 - 8.00.194 (Intel X86)

     Aug  6 2000 00:57:48

     Copyright (c) 1988-2000 Microsoft Corporation

     Personal Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

    Sql versions

    http://vyaskn.tripod.com/sqlsps.htm

  • Thanks for the reply. What I'm looking for is the client's OS, not the server's OS.

  • I doubt you'll get anything in SQL Server to provide client details. From SQL Servers perspective the client could be a server, workstation, web page, application, etc...

    You might be able to get the info via a WMI query after getting the host details from sysprocesses.

     

    --------------------
    Colt 45 - the original point and click interface

  • You can always use the xp_msver system extended stored proc.



    --------------------------
    Zach

    Odds_And_Ends Blog

  • I found the following VB code on the web that does what I need:

    Option Explicit

    '========================================================

    ' API Functions

    '========================================================

    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" & _

        (lpVersionInformation As OSVERSIONINFO) As Long

    '========================================================

    ' API Types

    '========================================================

    Private Type OSVERSIONINFO

        dwOSVersionInfoSize As Long

        dwMajorVersion As Long

        dwMinorVersion As Long

        dwBuildNumber As Long

        dwPlatformId As Long

        szCSDVersion As String * 128

    End Type

    '========================================================

    ' API Constants

    '========================================================

    Private Const VER_PLATFORM_WIN32_NT = 2

    Private Const VER_PLATFORM_WIN32_WINDOWS = 1

    Private Const VER_PLATFORM_WIN32s = 0

    '========================================================

    ' Shared Types

    '========================================================

    Public Type OS

        Name As String

        Version As String

    End Type

    '========================================================

    ' Shared Enums

    '========================================================

    Public Enum PlatformVersion

        pfvWin95 = 1

        pfvWin98 = 2

        pfvWinME = 3

        pfvWinNT351 = 4

        pfvWinNT40 = 5

        pfvWin2000 = 6

        pfvWinXP = 7

        pfvUnsupported = 998

        pfvError = 999

    End Enum

    '========================================================

    ' Shared Functions

    '========================================================

    Public Function BDIGetOS() As PlatformVersion

        Dim OSInfo As OSVERSIONINFO

        Dim lretval As Long

       

        'set the size of the structure

        OSInfo.dwOSVersionInfoSize = Len(OSInfo)

        'Get the version info from the computer

        lretval = GetVersionEx(OSInfo)

        'Check to see if the info was gathered

        If lretval = 0 Then

            'function errored

            BDIGetOS = Error

            Exit Function

        End If

       

        'determine the running version of windows

        Select Case OSInfo.dwMajorVersion

            Case 3 'Windows NT 3.51 only

                BDIGetOS = pfvWinNT351

            Case 4 'Win9x based or Windows NT 4.0

                Select Case OSInfo.dwMinorVersion

                    Case 0 'Windows 95 or Windows NT 4.0

                        Select Case OSInfo.dwPlatformId

                            Case VER_PLATFORM_WIN32_WINDOWS 'Windows 95

                                BDIGetOS = pfvWin95

                            Case VER_PLATFORM_WIN32_NT 'Windows NT 4.0

                                BDIGetOS = pfvWinNT40

                            Case Else 'unsupported

                                BDIGetOS = pfvUnsupported

                        End Select

                    Case 10 'Windows 98

                        BDIGetOS = pfvWin98

                    Case 90 'Windows ME

                        BDIGetOS = pfvWinME

                    Case Else 'error

                        BDIGetOS = pfvError

                End Select

            Case 5 'Windows 2000 or XP

                Select Case OSInfo.dwMinorVersion

                    Case 0 'Windows 2000

                        BDIGetOS = pfvWin2000

                    Case 1 'Windows XP

                        BDIGetOS = pfvWinXP

                    Case Else 'pfvUnsupported

                        BDIGetOS = pfvUnsupported

                End Select

            Case Else 'Unknown, return error

                BDIGetOS = pfvError

        End Select

    End Function

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

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